def password_reset(token):
"""Reset password using token.
"""
if not current_user.is_anonymous:
return redirect(url_for('.index'))
form = PasswordResetForm()
if form.validate_on_submit():
user = User.query.filter_by(email=form.email.data).first()
if user is None:
return redirect(url_for('.index'))
if user.reset_password(token, form.password.data):
flash('Your password has been updated.')
return redirect(url_for('auth.login'))
else:
return redirect(url_for('.index'))
return render_template('auth/reset_password.html', form=form)
评论列表
文章目录