Пример #1
0
def reset_password(request, user_id, pwd_reset_token):
    this_member = get_object_or_404(Member, id=user_id)
    token = pwd_reset_token
    if request.method == 'POST' and not this_member.is_pwd_reset_token_expired(token):
        form = ResetPasswordForm(this_member.user, request.POST)
        if form.save():
            messages.success(request, u'您的密码已经修改')
            this_member.delete_pwd_reset_token()
            return redirect('/')
    elif not this_member.is_pwd_reset_token_expired(token):
        form = ResetPasswordForm(request)
        ctx = { 'form': form,  }
    else:
        ctx = { 'status': 'failed' }
    return render(request, 'member/reset_password.html', ctx)
Пример #2
0
def reset_password(request, user_id, pwd_reset_token):
    try:
        this_member = Member.objects.get(id=user_id)
    except Member.DoesNotExist:
        raise Http404
    token = pwd_reset_token
    if request.method == 'POST' and not this_member.is_pwd_reset_token_expired(token):
        form = ResetPasswordForm(this_member.user, request.POST)
        if form.save():
            messages.success(request, u'您的密码已经修改')
            this_member.delete_pwd_reset_token()
            return redirect('/')
    elif not this_member.is_pwd_reset_token_expired(token):
        form = ResetPasswordForm(request)
        ctx = { 'form': form,  }
    else:
        ctx = { 'status': 'failed' }
    return render_to_response('member/reset_password.html', ctx, context_instance=RequestContext(request))
Пример #3
0
def reset_password(request, user_id, pwd_reset_token):
    this_member = get_object_or_404(Member, id=user_id)
    token = pwd_reset_token
    if request.method == 'POST' and not this_member.is_pwd_reset_token_expired(
            token):
        form = ResetPasswordForm(this_member.user, request.POST)
        if form.save():
            messages.success(request, u'您的密码已经修改')
            this_member.delete_pwd_reset_token()
            return redirect('/')
    elif not this_member.is_pwd_reset_token_expired(token):
        form = ResetPasswordForm(request)
        ctx = {
            'form': form,
        }
    else:
        ctx = {'status': 'failed'}
    return render(request, 'member/reset_password.html', ctx)