diff --git a/src/forms/user_forms.py b/src/forms/user_forms.py index e7d93e3..81bed8b 100644 --- a/src/forms/user_forms.py +++ b/src/forms/user_forms.py @@ -10,7 +10,7 @@ class LogInForm(FlaskForm): submit = SubmitField("Submit") -class CreateUserForm(FlaskForm): +class RegisterForm(FlaskForm): username = StringField( "Username", diff --git a/src/main.py b/src/main.py index eab0e73..a41bd12 100644 --- a/src/main.py +++ b/src/main.py @@ -1,7 +1,7 @@ from flask import Flask, flash, redirect, render_template, request, url_for from flask_login import LoginManager, login_required, login_user -from src.forms.user_forms import CreateUserForm, LogInForm +from src.forms.user_forms import RegisterForm, LogInForm from src.models import Base, SessionLocal, Users, engine from src.security import generate_password_hash @@ -34,12 +34,13 @@ def login(): user = Users.query.filter_by(username=username).first() - if user is not None and user.check_password(password, user.password_hash): + if user is None: + flash("That email does not exist. Please try again.", "danger") + elif not user.check_password(password, user.password_hash): + flash("Invalid password. Please try again.", "danger") + else: login_user(user) - flash("Logged in successfully!", "success") return redirect(url_for("dashboard")) - else: - flash("Invalid username or password", "danger") return render_template("login.html", form=form) @@ -52,7 +53,7 @@ def dashboard(): @app.route("/register", methods=["GET", "POST"]) def register(): - form = CreateUserForm() + form = RegisterForm() if form.validate_on_submit(): username = form.username.data password = form.password.data diff --git a/static/img/to_do_list.png b/static/img/to_do_list.png new file mode 100644 index 0000000..d855af0 Binary files /dev/null and b/static/img/to_do_list.png differ diff --git a/templates/base.html b/templates/base.html index cc4c190..dfa0847 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,7 +5,7 @@