From 7adaf3f22de239a4e1b3bf44302092996c6174da Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Mon, 8 Jul 2019 11:27:54 +0200 Subject: [PATCH] Add register view --- app/auth/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/auth/views.py b/app/auth/views.py index b2e6ba68..a566799d 100644 --- a/app/auth/views.py +++ b/app/auth/views.py @@ -1,7 +1,8 @@ from flask import flash, redirect, render_template, request, url_for from flask_login import login_required, login_user, logout_user from . import auth -from .forms import LoginForm, PasswordResetRequestForm +from .. import db +from .forms import LoginForm, PasswordResetRequestForm, RegistrationForm from ..email import send_email from ..models import User @@ -31,6 +32,14 @@ def logout(): @auth.route('/register', methods=['GET', 'POST']) 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')