def reset_password_request(): if current_user.is_authenticated: return redirect(url_for("main.home")) form = ResetPasswordRequestForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_password_reset_email(user) flash("Check your email for the instructions to reset your password") return redirect(url_for("auth.signin")) return render_template("reset-password-request.html", title="Reset Password", form=form)
def reset_password_request(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = ResetPasswordRequestForm() if form.validate_on_submit(): the_user = User.query.filter_by(email=form.email.data).first() if the_user: send_password_reset_email(the_user) flash('Check your email for the instructions to reset your password') return redirect(url_for('auth.login')) return render_template('auth/reset_password_request.html', title='Reset Password', form=form)
def password_reset_request(): form = ResetPasswordRequestForm() if current_user.is_authenticated: return redirect(url_for('main.index')) elif form.validate_on_submit(): user = User.query.filter_by(email=form.email.data.lower()).first() if user: token = user.generate_reset_token() send_email(subject='Reset Your Password', recipients=user.email, template_name='auth/email/reset', user=user, token=token) flash('An email with instructions has been sent to your inbox.') return redirect(url_for('main.index')) return render_template('auth/reset_password.html', form=form)