mirror of
https://github.com/TrentSPalmer/flask_photo_scaling_app.git
synced 2025-02-18 13:40:55 -08:00
fix style app/auth/reset_password.py
This commit is contained in:
parent
72a8b46375
commit
5eae85ca4a
@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from flask import Blueprint, redirect, url_for, flash, render_template, current_app
|
from flask import (
|
||||||
|
Blueprint, redirect, url_for, flash, render_template, current_app
|
||||||
|
)
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from app.models import Contributor
|
from app.models import Contributor
|
||||||
from app.forms import ResetPasswordForm, ResetPasswordRequestForm
|
from app.forms import ResetPasswordForm, ResetPasswordRequestForm
|
||||||
@ -25,7 +27,11 @@ def reset_password(token):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Your password has been reset.')
|
flash('Your password has been reset.')
|
||||||
return redirect(url_for('auths.login'))
|
return redirect(url_for('auths.login'))
|
||||||
return render_template('reset_password.html', title="New Password?", form=form)
|
return render_template(
|
||||||
|
'reset_password.html',
|
||||||
|
title="New Password?",
|
||||||
|
form=form,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pwd.route('/reset-password-request', methods=['GET', 'POST'])
|
@pwd.route('/reset-password-request', methods=['GET', 'POST'])
|
||||||
@ -35,12 +41,23 @@ def reset_password_request():
|
|||||||
else:
|
else:
|
||||||
form = ResetPasswordRequestForm()
|
form = ResetPasswordRequestForm()
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
contributor = Contributor.query.filter_by(email=form.email.data).first()
|
contributor = Contributor.query.filter_by(
|
||||||
|
email=form.email.data,
|
||||||
|
).first()
|
||||||
if contributor:
|
if contributor:
|
||||||
send_password_reset_email(contributor, current_app.config['EXTERNAL_URL'])
|
send_password_reset_email(
|
||||||
flash('Check your email for the instructions to reset your password')
|
contributor,
|
||||||
|
current_app.config['EXTERNAL_URL'],
|
||||||
|
)
|
||||||
|
my_flash = 'Check your email for the instructions '
|
||||||
|
my_flash += 'to reset your password'
|
||||||
|
flash(my_flash)
|
||||||
return redirect(url_for('auths.login'))
|
return redirect(url_for('auths.login'))
|
||||||
else:
|
else:
|
||||||
flash('Sorry, invalid email')
|
flash('Sorry, invalid email')
|
||||||
return redirect(url_for('auths.login'))
|
return redirect(url_for('auths.login'))
|
||||||
return render_template('reset_password_request.html', title='Reset Password', form=form)
|
return render_template(
|
||||||
|
'reset_password_request.html',
|
||||||
|
title='Reset Password',
|
||||||
|
form=form,
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user