Beispiel #1
0
def login():
    form = PasswordForm()
    if form.validate_on_submit() and form.password.data == PASSWORD:
        return facebook.authorize(callback=url_for("auth.facebook_authorized", _external=True,
                                                   _scheme=request.scheme, next=form.next.data))
    else:
        return render_template("error.html", msg="Where are you from, dude? Your password isn't correct")
Beispiel #2
0
def change_password(request):
    user = request.user
    if request.method == 'POST':
        passwordform = PasswordForm(request.POST)
        if passwordform.is_valid():
            if user.check_password(
                    passwordform.cleaned_data.get('current_password')):
                user.set_password(
                    passwordform.cleaned_data.get('new_password'))
                user.save()
                messages.success(
                    request, _('Your password has been modified successfully'))
            else:
                messages.error(request, _('Wrong password'))
        else:
            messages.error(request, _('Your password has not been modified'))
    else:
        passwordform = PasswordForm()

    return render_to_response('core/change_password.html', {
        'active': 'account',
        'title': _('Change password'),
        'passwordform': passwordform
    },
                              context_instance=RequestContext(request))
Beispiel #3
0
def change_password(request):
    user = request.user
    if request.method == 'POST':
        passwordform = PasswordForm(request.POST)
        if passwordform.is_valid():
            if user.check_password(passwordform.cleaned_data.get('current_password')):
                user.set_password(passwordform.cleaned_data.get('new_password'))
                user.save()
                messages.success(request, _('Your password has been modified successfully'))
            else:
                messages.error(request, _('Wrong password'))
        else:
            messages.error(request, _('Your password has not been modified'))
    else:
        passwordform = PasswordForm()

    return render_to_response('core/change_password.html',
                              {'active': 'account',
                               'title': _('Change password'),
                               'passwordform': passwordform},
                              context_instance=RequestContext(request))
Beispiel #4
0
def password_update(request):
    if request.user.is_authenticated:
        if request.method == 'POST':
            form = PasswordForm(user=request.user, data=request.POST)
            if form.is_valid():
                form.save()
                login(request, request.user)
                messages.success(request, 'Password successfully changed')
                return redirect('core:users')
        else:
            form = PasswordForm(user=request.user)

        for field in form.fields.values():
            field.help_text = None
    else:
        return redirect('core:auth_sign_in')

    return render(request, 'core/pages/users/password_update.html', {
        'form': form
    })