mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add email confirmation
This commit is contained in:
parent
30e82088b4
commit
ae11e04c6c
@ -36,15 +36,32 @@ def register():
|
||||
return redirect(url_for('main.index'))
|
||||
form = RegistrationForm()
|
||||
if form.validate_on_submit():
|
||||
user = User(email=form.email.data, username=form.username.data,
|
||||
user = User(email=form.email.data.lower(),
|
||||
username=form.username.data,
|
||||
password=form.password.data)
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
flash('Successfully registered! You can now login.')
|
||||
token = user.generate_confirmation_token()
|
||||
send_email(user.email, 'Confirm Your Account',
|
||||
'auth/email/confirm', user=user, token=token)
|
||||
flash('A confirmation email has been sent to you by email.')
|
||||
return redirect(url_for('auth.login'))
|
||||
return render_template('auth/register.html.j2', form=form)
|
||||
|
||||
|
||||
@auth.route('/confirm/<token>')
|
||||
@login_required
|
||||
def confirm(token):
|
||||
if current_user.confirmed:
|
||||
return redirect(url_for('main.index'))
|
||||
if current_user.confirm(token):
|
||||
db.session.commit()
|
||||
flash('You have confirmed your account. Thanks!')
|
||||
else:
|
||||
flash('The confirmation link is invalid or has expired.')
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
|
||||
@auth.route('/reset', methods=['GET', 'POST'])
|
||||
def password_reset_request():
|
||||
if not current_user.is_anonymous:
|
||||
|
Loading…
Reference in New Issue
Block a user