Adding test for LoginPage
This commit is contained in:
@@ -106,6 +106,15 @@ class RegisterPage:
|
||||
cls="btn w-full font-bold py-2 px-4 rounded"
|
||||
),
|
||||
|
||||
# Registration link
|
||||
Div(
|
||||
P(
|
||||
"Already have an account? ",
|
||||
A("Sign in here", href="/login", cls="text-blue-600 hover:underline"),
|
||||
cls="text-sm text-gray-600 text-center"
|
||||
)
|
||||
),
|
||||
|
||||
action="register-p",
|
||||
method="post",
|
||||
cls="mb-6"
|
||||
|
||||
@@ -45,7 +45,6 @@ def setup_auth_routes(app, rt, mount_auth_app=True):
|
||||
"""
|
||||
return LoginPage(error_message=error)
|
||||
|
||||
|
||||
@rt("/login-p")
|
||||
def post(email: str, password: str, session, redirect_url: str = "/"):
|
||||
"""
|
||||
@@ -99,6 +98,7 @@ def setup_auth_routes(app, rt, mount_auth_app=True):
|
||||
|
||||
Args:
|
||||
email: User email from form
|
||||
username: User name of the
|
||||
password: User password from form
|
||||
confirm_password: Password confirmation from form
|
||||
session: FastHTML session object
|
||||
@@ -107,12 +107,12 @@ def setup_auth_routes(app, rt, mount_auth_app=True):
|
||||
RegisterPage with success/error message via HTMX
|
||||
"""
|
||||
# Validate password confirmation
|
||||
# if password != confirm_password:
|
||||
# return RegisterPage(error_message="Passwords do not match. Please try again.")
|
||||
#
|
||||
# # Validate password length
|
||||
# if len(password) < 8:
|
||||
# return RegisterPage(error_message="Password must be at least 8 characters long.")
|
||||
if password != confirm_password:
|
||||
return RegisterPage(error_message="Passwords do not match. Please try again.")
|
||||
|
||||
# Validate password length
|
||||
if len(password) < 8:
|
||||
return RegisterPage(error_message="Password must be at least 8 characters long.")
|
||||
|
||||
# Attempt registration
|
||||
result = register_user(email, username, password)
|
||||
|
||||
Reference in New Issue
Block a user