def reset_request(): form = RequestResetForm() if form.validate_on_submit(): logout_user() user = User.query.filter_by(email=form.email.data).first() if user: confirm_url = generate_password_reset_url(user.email) html = render_template( "auth/email_password_reset_confirmation.html", confirm_url=confirm_url, first_name=user.first_name, last_name=user.last_name, ) subject = "Reset password request" send_email(user.email, subject, html) flash( "An email has been sent with instructions to reset your password.", "info", ) log( log.DEBUG, "An email has been sent with instructions to reset your password.", ) return render_template( "auth/reset_password_request.html", title="Reset Password", form=form, dashboards=accessed_links(), )
def request_reset(): form = RequestResetForm() if form.validate_on_submit(): user = None try: user = User.query.filter(User.email == form.email.data).one() except: pass if user: email = user.email reset_token = generate_token(email) email_body = '<a href="{}">Click here</a> to reset your snip.space password.'\ .format(url_for('user.reset_password', reset_token=reset_token, _external=True)) send_email.delay(email, 'Password Reset for snip.space', email_body) message = """A link to reset your password has been sent to the email address <strong>{}</strong>. Check your email, and follow the provided link to continue.""".format(email) return render_template('message.html', title="Reset Email Sent", message=message) else: flash('Email not found in our records.', 'danger') return redirect(url_for('user.request_reset')) return render_template('user/request_reset.html', form=form)
def forgot_password_page(): if current_user.is_authenticated: return redirect(url_for('home_page')) form = RequestResetForm() if form.validate_on_submit(): flash(f'Email sent!', 'success') return redirect(url_for('home_page')) return render_template('forgot_pw.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('invalid_action')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) return render_template('reset_password_token_sent.html', title="Reset Password", email=form.email.data) return render_template('reset_password.html', title="Reset Password", form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash('重置邮件已发送至您的邮箱,请查收', 'info') return redirect(url_for('login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash('Email ünvanınıza şifrə yeniləməsi üçün link göndərildi.', 'info') return redirect(url_for('login')) return render_template('app/user/reset_request.html', title='Şifrəni Yeniləmək Üçün Sorğu Göndər', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('index')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash('An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('home')) form = RequestResetForm() # Form från forms.py if form.validate_on_submit(): # OM SubmitField klickas, kör nedan user = User.query.filter_by(email=form.email.data).first() # Kollar i databasen om det finns en användare med angiven email, if so, hämta objektet send_reset_email(user) # Anropa funktionen send_reset_email() (se nedan), och skicka med user-objektet flash('An email has beeen sent to restore the password.', 'info') # Gul banner ('info') som säger att att återställningsmail har skickats till angiven email return redirect(url_for('login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) return redirect(url_for('main.reset_request')) return render_template("reset_request.html", title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('mgb')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by( email=form.email.data.strip().lower()).first() send_reset_email(user) flash('Die Email zum Zurücksetzen deines Passwortes wurde versendet.', 'success') return redirect(url_for('login')) return render_template('pages/reset_request.html', title="Passwort zurücksetzten", form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('postime')) form = RequestResetForm() if form.validate_on_submit(): user = Perdorues.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'Nje email verifikimi u dergua. Ju lutem kontrolloni inboxin tuaj!', 'info') return redirect(url_for('hyr')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('home')) form = RequestResetForm() if form.validate_on_submit(): customer = Customer.query.filter_by(email=form.email.data).first() if customer is None: foodseller = Foodseller.query.filter_by(email=form.email.data).first() send_reset_email_foodseller(foodseller) flash('An email has been sent to reset your password') return redirect(url_for('login')) else: send_reset_email_customer(customer) flash('An email has been sent to reset your password') return redirect(url_for('login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect('/') form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() token = user.get_reset_token() send_mail( '*****@*****.**', user.email, 'Reset Password', 'Click the following link to reset your password:'******'reset_token', token=token, _external=True)) flash('~Password Reset Email Sent.') return redirect('/') else: flash_errors(form, '`') return redirect('/')
def reset_request(): """ Route for requesting password reset. """ if current_user.is_authenticated: return redirect(url_for('home')) form = RequestResetForm() if form.validate_on_submit(): user = Appuser.query.filter_by(email=form.email.data).first() send_email_to_reset_password(user) flash('Email with instruction has been sent to your email address', 'info') return redirect(url_for('login')) return render_template('reset_request.html', title='Request Password Reset', form=form)
def reset_passsword_request(): if current_user.is_authenticated: return redirect(url_for('index')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email = form.email.data).first() if user: token = user.get_reset_token() body = f'''To reset your password, visit the following link : {url_for('reset_password',token=token,_external=True)} If you did not make this request then simply ignore this mail and no changes will be done.''' subject = "Central Library - Password Reset Request" #The _external is set to True to identify that it is an active url rather than a relative url like in flask# thr = Thread(target=async_mail, args = (app, body, subject, user.email)) thr.start() flash("A password reset link has been sent to your email-address.", "info") return redirect(url_for('login')) return render_template('reset_request.html', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: token = user.get_reset_token() msg = Message("Hello", sender="*****@*****.**", recipients=[user.email]) msg.body = f'''Click on the link to reset your password f{url_for('reset_token', token=token, _external=True)}''' mail.send(msg) flash( "An email has has been sent with instructions to reset your password", "info") return redirect(url_for('login')) else: flash( f"There is no account registered with\ this email, register{url_for('login')}", "warning") return render_template("reset_request.html", form=form)
def render_home(page, event=None): if current_user.is_authenticated: events = current_user.rel return render_template( 'home.html', user=current_user, lform=LoginForm(), sform=SignupForm(), eform=EventForm(), pform=RequestResetForm(), iform=InviteToEventForm(), aform=ScheduleForm(), psform=PScheduleForm(), eventPlaceholder=random.choice(eventPlaceholders), startPage=page, event=event, schedule=(None if (event is None) else Schedule(event)), userEvents=(current_user.rel if current_user.is_authenticated else None))