Exemple #1
0
def password_reset():
    # If already logged in, redirect to the logged in reset form
    ipa = maybe_ipa_session(app, session)
    username = session.get('noggin_username')
    if ipa and username:
        return redirect(url_for('user_settings_password', username=username))

    username = request.args.get('username')
    if not username:
        abort(404)
    form = PasswordResetForm()

    if form.validate_on_submit():
        res = _validate_change_pw_form(form, username)
        if res and res.ok:
            return redirect(url_for('root'))

    return render_template('password-reset.html',
                           password_reset_form=form,
                           username=username)
Exemple #2
0
def user_settings_password(ipa, username):
    user = User(user_or_404(ipa, username))
    form = PasswordResetForm()

    # check if an OTP token exists. If so, the user is using OTP.
    using_otp = bool(ipa.otptoken_find(ipatokenowner=username))

    if not using_otp:
        form.current_password.description = ""

    if form.validate_on_submit():
        res = _validate_change_pw_form(form, username, ipa)
        if res and res.ok:
            return redirect(url_for('root'))

    return render_template(
        'user-settings-password.html',
        user=user,
        password_reset_form=form,
        activetab="password",
        using_otp=using_otp,
    )