Tracking PR for registration rewrite #5

Merged
Muirrum merged 32 commits from rewrite into master 2022-12-15 18:32:08 -05:00
6 changed files with 43 additions and 0 deletions
Showing only changes of commit fecb0e08ab - Show all commits

View file

@ -19,4 +19,8 @@ def create_app():
from .models import User from .models import User
from . import registration
app.register_blueprint(registration.bp)
return app return app

View file

@ -1,6 +1,8 @@
from flask import flash, redirect, url_for
from flask_login import UserMixin from flask_login import UserMixin
from sqlalchemy import Boolean, Column, DateTime, Integer, String from sqlalchemy import Boolean, Column, DateTime, Integer, String
from . import db from . import db
from . import login
class User(db.Model, UserMixin): class User(db.Model, UserMixin):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
@ -11,3 +13,13 @@ class User(db.Model, UserMixin):
last_login = Column(DateTime, nullable=False) last_login = Column(DateTime, nullable=False)
active = Column(Boolean, nullable=False, default=True) active = Column(Boolean, nullable=False, default=True)
is_admin = Column(Boolean, nullable=False, default=False) is_admin = Column(Boolean, nullable=False, default=False)
@login.user_loader
def user_loader(user_id):
return User.query.filter_by(id=user_id).first()
@login.unauthorized_handler
Muirrum commented 2022-12-08 20:25:22 -05:00 (Migrated from github.com)
Review

@willhockey20 is this something that actually needs to be stored? I only included it bc it was in the original registration system.

@willhockey20 is this something that actually needs to be stored? I only included it bc it was in the original registration system.
wfryan commented 2022-12-08 20:29:57 -05:00 (Migrated from github.com)
Review

The data was required by mlh, still could be nice to have so I'd keep it

The data was required by mlh, still could be nice to have so I'd keep it
def unauth():
flash("Please login first")
return redirect(url_for("registration.register"))

View file

@ -0,0 +1,12 @@
from flask import Blueprint, flash
from flask_login import current_user
bp = Blueprint('registration', __name__, url_prefix="/registration")
@bp.route("/")
def register():
if current_user.is_authenticated:
flash("You are already registered and logged in!")

View file

@ -0,0 +1,13 @@
from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField
from wtforms.validators import DataRequired
class RegisterForm(FlaskForm):
email = StringField("Email", validators=[DataRequired()])
Muirrum commented 2022-12-07 09:03:42 -05:00 (Migrated from github.com)
Review

This could probably get turned into an EmailField if we cared enough

This could probably get turned into an `EmailField` if we cared enough
first_name = StringField("Preferred First Name",
validators=[DataRequired()])
last_name = StringField("Last Name", validators=[DataRequired()])
password = PasswordField("Password", validators=[DataRequired()])
password_confirm = PasswordField("Confirm Password",
validators=[DataRequired()])

View file

View file

@ -4,6 +4,7 @@ Flask==2.2.2
Flask-Login==0.6.2 Flask-Login==0.6.2
Flask-Migrate==4.0.0 Flask-Migrate==4.0.0
Flask-SQLAlchemy==3.0.2 Flask-SQLAlchemy==3.0.2
Flask-WTF==1.0.1
greenlet==2.0.1 greenlet==2.0.1
itsdangerous==2.1.2 itsdangerous==2.1.2
Jinja2==3.1.2 Jinja2==3.1.2
@ -17,3 +18,4 @@ python-dotenv==0.21.0
SQLAlchemy==1.4.44 SQLAlchemy==1.4.44
uWSGI==2.0.21 uWSGI==2.0.21
Werkzeug==2.2.2 Werkzeug==2.2.2
WTForms==3.0.1