-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
from flask_wtf import FlaskForm | ||
from wtforms import StringField, PasswordField, BooleanField, SubmitField | ||
from wtforms.validators import DataRequired | ||
from wtforms.validators import Email | ||
from wtforms.validators import ValidationError | ||
from wtforms.validators import EqualTo | ||
|
||
from app import User | ||
|
||
class LoginForm(FlaskForm): | ||
""" | ||
Class for handling login for the page | ||
""" | ||
username = StringField("Username", validators=[DataRequired()]) | ||
password = PasswordField ("Password", validators=[DataRequired()]) | ||
remember_me = BooleanField("Remember Me?") | ||
submit = SubmitField("Sign In") | ||
submit = SubmitField("Sign In") | ||
|
||
class RegistrationForm(FlaskForm): | ||
""" | ||
Handles User registration | ||
Creates a new user in the database | ||
""" | ||
username = StringField("Username", validators=[DataRequired()]) | ||
email = StringField("Email",validators=[DataRequired(),Email()]) | ||
password = PasswordField ("Password", validators=[DataRequired()]) | ||
password_repeat = PasswordField( | ||
"Repeat Password", | ||
validators = [DataRequired(),EqualTo("password")]) | ||
submit = SubmitField("Register") | ||
|
||
def validate_username(self, username): | ||
user = User.query.filter_by(username = username.data).first() | ||
if user is not None: | ||
raise ValidationError("Invalid Username, already taken") | ||
|
||
def validate_email(self, email): | ||
user = User.query.filter_by(email= email.data).first() | ||
if user is not None: | ||
raise ValidationError("Email already registered, please reset your password") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters