Esempio n. 1
0
def password_reset_key_done(request, key=None):
    d = {'clientip': request.META['REMOTE_ADDR'], 'user': request.user}
    data = getsiteandmenus(request)
    form = ChangePasswordForm()
    note = _("Change your password")
    try:
        user_verification = UserVerification.objects.get(password_reset_key=key)
        user = user_verification.user
        user.is_authenticated = False
        user.save()
        request.user = user
    except Exception as e:
        note = _("""Password reset operation failed""")
        log.error(e.message, extra=d)
    if request.method == 'POST':
        form = ChangePasswordForm(request.POST)
        if form.is_valid():
            try:
                request.user.set_password(form.cleaned_data['password'])
                request.user.save()
                note = _("""Your password has been changed""")
                form = None
                redirect("index")
            except Exception as e:
                note = _("""Your password couldn't be changed""")
                log.error(e.message, extra=d)
    data['changepasswordform'] = form
    data['note'] = note
    data['user'] = request.user
    return render_to_response("userprofile/change_password.html", data, context_instance=RequestContext(request))
Esempio n. 2
0
def password_reset_key_done(request, key=None):
    data = {'note': _("Change your password")}
    form = ChangePasswordForm()
    try:
        user_verification = UserVerification.objects.get(
            password_reset_key=key)
        user = user_verification.user
        user.is_authenticated = False
        user.save()
        request.user = user
    except Exception as e:
        data['note'] = _("""Password reset operation failed""")
        log.error(e.message, extra=request.log_extra)
    if request.method == 'POST':
        form = ChangePasswordForm(request.POST)
        if form.is_valid():
            try:
                request.user.set_password(form.cleaned_data['password'])
                request.user.save()
                data['note'] = _("""Your password has been changed""")
                form = None
                redirect("index")
            except Exception as e:
                data['note'] = _("""Your password couldn't be changed""")
                log.error(e.message, extra=request.log_extra)
    data['changepasswordform'] = form
    data['user'] = request.user
    return render(request, "userprofile/change_password.html", data)
Esempio n. 3
0
def password_reset(request):
    data = {"note": _("Change your password")}
    form = ChangePasswordForm()
    if request.method == 'POST':
        form = ChangePasswordForm(request.POST)
        if form.is_valid():
            try:
                request.user.set_password(form.cleaned_data['password'])
                request.user.save()
                # noinspection PyTypeChecker
                backend_login(request, request.user)
                data['note'] = _("Your password has been changed")
                form = None
            except Exception as e:
                data['note'] = _("Your password couldn't be changed")
                log.error(e.message, extra=request.log_extra)
    data['changepasswordform'] = form
    return render(request, "userprofile/change_password.html", data)
Esempio n. 4
0
def password_reset(request):
    d = {'clientip': request.META['REMOTE_ADDR'], 'user': request.user}
    data = getsiteandmenus(request)
    form = ChangePasswordForm()
    note = _("Change your password")
    if request.method == 'POST':
        form = ChangePasswordForm(request.POST)
        if form.is_valid():
            try:
                request.user.set_password(form.cleaned_data['password'])
                request.user.save()
                backend_login(request, request.user)
                note = _("""Your password has been changed""")
                form = None
            except Exception as e:
                note = _("""Your password couldn't be changed""")
                log.error(e.message, extra=d)
    data['changepasswordform'] = form
    data['note'] = note
    return render_to_response("userprofile/change_password.html", data, context_instance=RequestContext(request))