From 48d07f3d78e310c4bf924cdd8a3e640bc3e2f4fe Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Sat, 14 Oct 2023 21:13:37 -0400 Subject: [PATCH] Updates for user --- htmx_contact/static/css/main.css | 18 ++++++++++++++++-- htmx_contact/templates/contacts.html | 2 +- htmx_contact/templates/login.html | 21 ++++++++++++++------- htmx_contact/templates/new_contact.html | 2 +- htmx_contact/user.py | 17 +++++++++++------ 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/htmx_contact/static/css/main.css b/htmx_contact/static/css/main.css index 1469379..5f93e7d 100644 --- a/htmx_contact/static/css/main.css +++ b/htmx_contact/static/css/main.css @@ -25,7 +25,8 @@ } input[type=text], -input[type=email] { +input[type=email], +input[type=password] { padding: 10px 5px; border-radius: .25rem; border: 2px solid black; @@ -35,7 +36,11 @@ input[type=email] { body { font-family: 'Roboto', "Helvetica Neue"; - font-size: 16px; + font-size: 18px; + background-color: #f9fafb; + color: #1f2937; + -webkit-font-smoothing: antialiased; + font-weight: 400; } a { @@ -60,6 +65,7 @@ table a:hover { border: none; border-radius: .25rem; font-size: 16px; + font-weight: 600; } .button:hover { @@ -165,3 +171,11 @@ form span { .width-100 { width: 100%; } + +.mb-4 { + margin-bottom: 1rem; +} + +.flex-right { + justify-content: right; +} diff --git a/htmx_contact/templates/contacts.html b/htmx_contact/templates/contacts.html index 7a3ff76..8024d24 100644 --- a/htmx_contact/templates/contacts.html +++ b/htmx_contact/templates/contacts.html @@ -7,7 +7,7 @@
- +
Add Contact diff --git a/htmx_contact/templates/login.html b/htmx_contact/templates/login.html index c5b02a3..abfd735 100644 --- a/htmx_contact/templates/login.html +++ b/htmx_contact/templates/login.html @@ -1,11 +1,18 @@ {% extends 'base.html' %} {% block content %} -
- - - - - -
+
+
+

Login

+
+ + + + +
+ +
+
+
+
{% endblock %} diff --git a/htmx_contact/templates/new_contact.html b/htmx_contact/templates/new_contact.html index f24802c..67dd47d 100644 --- a/htmx_contact/templates/new_contact.html +++ b/htmx_contact/templates/new_contact.html @@ -2,7 +2,7 @@ {% block content %}
-
+

New Contact

diff --git a/htmx_contact/user.py b/htmx_contact/user.py index 3fbda38..6aa04fa 100644 --- a/htmx_contact/user.py +++ b/htmx_contact/user.py @@ -1,5 +1,6 @@ import logging +from argon2.exceptions import VerifyMismatchError from flask import Blueprint from flask import abort from flask import flash @@ -42,14 +43,18 @@ def user_login(): with Session() as session: select_user_stmt = select(User).where(User.primary_email == data.email) user = session.scalar(select_user_stmt) - if user is not None and user.check_password(data.password): - # Login and redirect from where they came from - fl_login_user(user=user) - flash("Welcome back {}.".format(user.username)) - return redirect(request.args.get("next") or url_for("main.contacts")) + try: + if user is not None: + user.check_password(data.password) + # Login and redirect from where they came from + fl_login_user(user=user) + flash("Welcome back {}.".format(user.username)) + return redirect(request.args.get("next") or url_for("main.contacts")) # User was None or password was incorrect + except VerifyMismatchError: + logger.warning("User %s failed password verfication.", user.id) flash("Incorrect username or password") - return render_template("login.html") + return render_template("login.html") else: return render_template("login.html")