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)
评论列表
文章目录