mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add password reset request view.
This commit is contained in:
parent
4076e44194
commit
dd4fcdfe20
@ -1,7 +1,8 @@
|
|||||||
from flask import flash, redirect, render_template, request, url_for
|
from flask import flash, redirect, render_template, request, url_for
|
||||||
from flask_login import login_required, login_user, logout_user
|
from flask_login import login_required, login_user, logout_user
|
||||||
from . import auth
|
from . import auth
|
||||||
from .forms import LoginForm
|
from .forms import LoginForm, PasswordResetRequestForm
|
||||||
|
from ..email import send_email
|
||||||
from ..models import User
|
from ..models import User
|
||||||
|
|
||||||
|
|
||||||
@ -31,3 +32,18 @@ def logout():
|
|||||||
@auth.route('/register', methods=['GET', 'POST'])
|
@auth.route('/register', methods=['GET', 'POST'])
|
||||||
def register():
|
def register():
|
||||||
return render_template('auth/register.html.j2')
|
return render_template('auth/register.html.j2')
|
||||||
|
|
||||||
|
|
||||||
|
@auth.route('/reset', methods=['GET', 'POST'])
|
||||||
|
def password_reset_request():
|
||||||
|
form = PasswordResetRequestForm()
|
||||||
|
if form.validate_on_submit():
|
||||||
|
user = User.query.filter_by(email=form.email.data.lower()).first()
|
||||||
|
if user:
|
||||||
|
token = user.generate_reset_token()
|
||||||
|
send_email(user.email, 'Reset Your Password',
|
||||||
|
'auth/email/reset_password',
|
||||||
|
user=user, token=token)
|
||||||
|
flash('An email with instructions to reset your password has been '
|
||||||
|
'sent to you.')
|
||||||
|
return redirect(url_for('auth.login'))
|
||||||
|
Loading…
Reference in New Issue
Block a user