Skip to content

Commit 8f8f301

Browse files
First pass refactor of profile.html to add separate email update section
1 parent c390f51 commit 8f8f301

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

routers/user.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
class UpdateProfile(BaseModel):
1717
"""Request model for updating user profile information"""
1818
name: str
19-
email: EmailStr
2019
avatar_file: Optional[bytes] = None
2120
avatar_content_type: Optional[str] = None
2221

2322
@classmethod
2423
async def as_form(
2524
cls,
2625
name: str = Form(...),
27-
email: EmailStr = Form(...),
2826
avatar_file: Optional[UploadFile] = File(None),
2927
):
3028
avatar_data = None
@@ -36,7 +34,6 @@ async def as_form(
3634

3735
return cls(
3836
name=name,
39-
email=email,
4037
avatar_file=avatar_data,
4138
avatar_content_type=avatar_content_type
4239
)
@@ -73,7 +70,6 @@ async def update_profile(
7370

7471
# Update user details
7572
user.name = user_profile.name
76-
user.email = user_profile.email
7773

7874
if user_profile.avatar_file:
7975
user.avatar_data = user_profile.avatar_file

templates/users/profile.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ <h1 class="mb-4">User Profile</h1>
4040
<label for="name" class="form-label">Name</label>
4141
<input type="text" class="form-control" id="name" name="name" value="{{ user.name }}">
4242
</div>
43-
<div class="mb-3">
44-
<label for="email" class="form-label">Email</label>
45-
<input type="email" class="form-control" id="email" name="email" value="{{ user.email }}">
46-
</div>
4743
<div class="mb-3">
4844
<label for="avatar_file" class="form-label">Avatar</label>
4945
<input type="file" class="form-control" id="avatar_file" name="avatar_file" accept="image/*">
@@ -62,13 +58,29 @@ <h1 class="mb-4">User Profile</h1>
6258
</div>
6359
</div>
6460

61+
<!-- New Email Update Section -->
62+
<div class="card mb-4">
63+
<div class="card-header">
64+
Update Email
65+
</div>
66+
<div class="card-body">
67+
<form action="{{ url_for('request_email_update') }}" method="post">
68+
<div class="mb-3">
69+
<label for="new_email" class="form-label">New Email Address</label>
70+
<input type="email" class="form-control" id="new_email" name="new_email" value="{{ user.email }}">
71+
</div>
72+
<p class="form-text">A confirmation link will be sent to your new email address to verify the change.</p>
73+
<button type="submit" class="btn btn-primary">Update Email</button>
74+
</form>
75+
</div>
76+
</div>
77+
6578
<!-- Change Password -->
6679
<div class="card mb-4">
6780
<div class="card-header">
6881
Change Password
6982
</div>
7083
<div class="card-body">
71-
<!-- TODO: Trigger password reset via email confirmation -->
7284
<form action="{{ url_for('forgot_password') }}" method="post">
7385
<input type="hidden" name="email" value="{{ user.email }}">
7486
<p>To change your password, please confirm your email. A password reset link will be sent to your email address.</p>

0 commit comments

Comments
 (0)