コード例 #1
0
def reset_password(token):
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    user = User.verify_reset_password_token(token)
    if not user:
        return redirect(url_for('main.index'))
    form = ResetPasswordForm()
    if form.validate_on_submit():
        user.set_password(form.password.data)
        db.session.commit()
        flash(_l('Your password has been reset.'))
        return redirect(url_for('auth.login'))
    return render_template('auth/reset_password.html', form=form)
コード例 #2
0
ファイル: routes.py プロジェクト: ted19b/micro_blog
def reset_password(token):
    if current_user.is_authenticated:
        return redirect(url_for('main.dashboard'))

    user = User.verify_reset_password_token(token)
    if not user:
        flash(_('Your token has expired, please restart the process'),
              'warning')
        return redirect(url_for('main.home'))

    form = ResetPasswordForm()
    if form.validate_on_submit():
        user.set_password(form.new_password.data)
        db.session.commit()
        flash(_('Your password has been reset'), 'success')
        return redirect(url_for('auth.login'))

    return render_template('auth/reset_password.html',
                           title='Reset Password',
                           form=form)