Skip to content

Commit 4747ba6

Browse files
Reconcile delete account form with new backend route expectations
1 parent 5b06ef7 commit 4747ba6

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

routers/account.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ async def delete_account(
102102
)
103103

104104
# Delete the account and associated user
105-
# Note: The user will be deleted automatically due to the cascade relationship,
106-
# but we need to refresh the session to ensure the changes are committed properly
105+
# Note: The user will be deleted automatically by cascade relationship
107106
session.delete(account)
108107
session.commit()
109108

@@ -141,7 +140,7 @@ async def read_register(
141140

142141
return templates.TemplateResponse(
143142
"authentication/register.html",
144-
{"request": request, "user": user}
143+
{"request": request, "user": user, "password_pattern": HTML_PASSWORD_PATTERN}
145144
)
146145

147146

templates/authentication/register.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
<input type="text" class="form-control" id="name" name="name" placeholder="Enter your name" required
1414
autocomplete="name">
1515
</div>
16-
16+
1717
<!-- Email Input -->
1818
<div class="mb-3">
1919
<label for="email" class="form-label">Email</label>
2020
<input type="email" class="form-control" id="email" name="email" placeholder="Enter your email" required
2121
autocomplete="email">
2222
</div>
23-
23+
2424
<!-- Password Input -->
2525
<div class="mb-3">
2626
<label for="password" class="form-label">Password</label>
@@ -33,7 +33,7 @@
3333
Must contain at least one number, one uppercase and lowercase letter, one special character, and at least 8 or more characters
3434
</div>
3535
</div>
36-
36+
3737
<!-- Confirm Password Input -->
3838
<div class="mb-3">
3939
<label for="confirm_password" class="form-label">Confirm Password</label>
@@ -44,13 +44,13 @@
4444
Passwords do not match.
4545
</div>
4646
</div>
47-
47+
4848
<!-- Submit Button -->
4949
<div class="d-grid">
5050
<button type="submit" class="btn btn-primary">Register</button>
5151
</div>
5252
</form>
53-
53+
5454
<!-- Login Link -->
5555
<p class="mt-3 text-center">Already have an account? <a href="{{ url_for('read_login') }}">Login here</a></p>
5656
</div>

templates/users/profile.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ <h1 class="mb-4">User Profile</h1>
115115
</div>
116116
<div class="card-body">
117117
<form action="{{ url_for('delete_account') }}" method="post">
118-
<p class="text-danger">This action cannot be undone. Please confirm your password to delete your account.</p>
118+
<p class="text-danger">This action cannot be undone. Please confirm your email and password to delete your account.</p>
119119
<div class="mb-3">
120-
<input type="hidden" name="email" value="{{ user.account.email }}">
121-
<label for="password" class="form-label">Password</label>
122-
<input type="password" class="form-control" id="password" name="password" autocomplete="off">
120+
<label for="delete_email" class="form-label">Email</label>
121+
<input type="email" class="form-control" id="delete_email" name="email" autocomplete="off">
122+
</div>
123+
<div class="mb-3">
124+
<label for="delete_password" class="form-label">Password</label>
125+
<input type="password" class="form-control" id="delete_password" name="password" autocomplete="off">
123126
</div>
124127
<button type="submit" class="btn btn-danger">Delete Account</button>
125128
</form>

tests/test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
send_email_update_confirmation
1919
)
2020
from unittest.mock import patch, MagicMock
21-
from utils.models import Account, EmailUpdateToken
21+
from utils.models import EmailUpdateToken
2222

2323

2424
def test_convert_python_regex_to_html() -> None:

0 commit comments

Comments
 (0)