routes.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:do-portal 作者: certeu 项目源码 文件源码
def set_password(token):
    """Set initial customer password. The template for this route contains
    bootstrap.css, bootstrap-theme.css and main.css.

    This is similar to the password reset option with two exceptions:
    it has a longer expiration time and does not require old password.

    :param token: Token generated by
        :meth:`app.models.User.generate_reset_token`

    :return:
    """
    s = TimedJSONWebSignatureSerializer(current_app.config['SECRET_KEY'])
    try:
        s.loads(token)
    except BadSignature:
        flash('Signature expired.')
        return redirect(url_for('main.index'))
    form = SetPasswordForm()
    if form.validate_on_submit():
        User.set_password(token, form.data['password'])
        flash('Your new password has been set.')
        return redirect(url_for('main.index'))
    for field, err in form.errors.items():
        flash(err[0], 'danger')
    return render_template('auth/set_password.html', form=form, token=token)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号