mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add register view
This commit is contained in:
parent
073b0e0e05
commit
7adaf3f22d
@ -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, PasswordResetRequestForm
|
from .. import db
|
||||||
|
from .forms import LoginForm, PasswordResetRequestForm, RegistrationForm
|
||||||
from ..email import send_email
|
from ..email import send_email
|
||||||
from ..models import User
|
from ..models import User
|
||||||
|
|
||||||
@ -31,6 +32,14 @@ def logout():
|
|||||||
|
|
||||||
@auth.route('/register', methods=['GET', 'POST'])
|
@auth.route('/register', methods=['GET', 'POST'])
|
||||||
def register():
|
def register():
|
||||||
|
form = RegistrationForm()
|
||||||
|
if form.validate_on_submit():
|
||||||
|
user = User(email=form.email.data, username=form.username.data,
|
||||||
|
password=form.password.data)
|
||||||
|
db.session.add(user)
|
||||||
|
db.session.commit()
|
||||||
|
flash('Successfully registered! You can now login.')
|
||||||
|
return redirect(url_for('auth.login'))
|
||||||
return render_template('auth/register.html.j2')
|
return render_template('auth/register.html.j2')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user