def reset_password_request(): """ Description ----------- This function takes the user to the web page where they can initiate a password reset request. Params ------ None Return ------ Returns a rendered Jinja2 HTML template served over the flask application under the `/reset_password/<token>' path """ if current_user.is_authenticated: return redirect(url_for('index')) form = PasswordResetRequestForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data.lower()).first() if user: send_password_reset_email(user) flash( 'A password reset has been sent to that email if a profile exists.' ) return redirect(url_for('login')) return render_template( 'reset_password_request.html', form=form, header='Well get on it then!', footer= 'Once you submit there will only be 10 minutes to reset you password. Good Luck!' )
def password_reset(): if current_user.is_authenticated: return redirect(url_for('home')) form = PasswordResetRequestForm() if request.method == 'POST' and form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() reset_email_sender(user) flash('Password reset token was sended to your email. Check inbox:)', 'info') return redirect(url_for('login')) return render_template('password_reset.html', form=form)
def password_reset(): if current_user.is_authenticated: return redirect(url_for('home')) form = PasswordResetRequestForm() if request.method == 'POST' and form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() flash('Password reset token was sended', 'success') print('Sending email to:', user.email, "\n\nWith token:", user.get_password_reset_token()) return redirect(url_for('password_reset')) return render_template('password_reset.html', form=form)
def send_password_reset_request(): if current_user.is_authenticated: return redirect(url_for('index')) form = PasswordResetRequestForm() if form.validate_on_submit(): email = form.email.data user = User.query.filter_by(email=email).first() token = user.generate_reset_password_token() send_reset_password_mail(user, token) flash('Password reset request mail is sent, please check your email', category='info') return render_template('send_password_reset_request.html', form=form)
def resetpassword(): if current_user.is_authenticated: return redirect(url_for('profile')) form = PasswordResetRequestForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: send_reset_email(user) flash('Please check your email for instructions on resetting your password.', 'success') return redirect(url_for('login')) else: flash('There is no such account with that email. Please try again.', 'warning') return redirect(url_for('resetpassword')) return render_template('resetpassword.html', form=form)
def password_reset_request(): form = PasswordResetRequestForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: token = user.generate_reset_token() send_email(user.email, u'重置您的密码', 'reset_password', user=user, token=token) flash(u'一封带有重置密码链接的邮件已发往您的邮箱') return redirect(url_for('login')) return render_template('reset_password0.html', form=form)
def password_reset_request(): """Render the password reset request page.""" if current_user.is_authenticated: return redirect(url_for('dashboard')) form = PasswordResetRequestForm() if form.validate_on_submit(): user = Users.query.filter_by(Email=form.email.data).first() if user: email_password_reset(user) flash('Check your email for the link to reset your password') return redirect(url_for('login')) return render_template('password_reset_request.html', title='Password Reset Request', form=form)
def password_reset_request(): if current_user.is_authenticated: return redirect(url_for('index')) form = PasswordResetRequestForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: send_password_reset_mail(user) flash( u'check your email for instructions regarding the password reset', 'message') return redirect(url_for('login')) return render_template('password_reset_request.html', title='Reset password', form=form)
def reset_password_request(): if current_user.is_authenticated: return redirect(url_for('index')) form = PasswordResetRequestForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: send_password_reset_mail(user) flash( _('Check your email for instructions to reset your password')) return redirect(url_for('login')) else: flash(_('Enter email you used to sign up')) return render_template('reset_password_request.html', title='Reset password', form=form)
def send_password_reset_request(): if current_user.is_authenticated: #如果已經是登入狀態就回到INDEX return redirect(url_for('index')) form = PasswordResetRequestForm() return render_template('send_password_reset_request.html', form=form)