File tree Expand file tree Collapse file tree 3 files changed +27
-16
lines changed Expand file tree Collapse file tree 3 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -357,19 +357,31 @@ async def confirm_email_update(
357
357
if not user or not update_token :
358
358
raise AuthenticationError ()
359
359
360
- # Get the new email from the most recent unconfirmed token
361
- if update_token .is_expired ():
362
- raise HTTPException (
363
- status_code = 400 ,
364
- detail = "Token has expired"
365
- )
366
-
367
360
# Update email and mark token as used
368
361
user .email = new_email
369
362
update_token .used = True
370
363
session .commit ()
371
364
372
- return RedirectResponse (
373
- url = "/login?email_updated=true" ,
365
+ # Create new tokens with the updated email
366
+ access_token = create_access_token (data = {"sub" : new_email })
367
+ refresh_token = create_refresh_token (data = {"sub" : new_email })
368
+
369
+ response = RedirectResponse (
370
+ url = "/profile?email_updated=true" ,
374
371
status_code = 303
375
372
)
373
+ response .set_cookie (
374
+ key = "access_token" ,
375
+ value = access_token ,
376
+ httponly = True ,
377
+ secure = True ,
378
+ samesite = "strict"
379
+ )
380
+ response .set_cookie (
381
+ key = "refresh_token" ,
382
+ value = refresh_token ,
383
+ httponly = True ,
384
+ secure = True ,
385
+ samesite = "strict"
386
+ )
387
+ return response
Original file line number Diff line number Diff line change 6
6
7
7
{% block auth_content %}
8
8
< div class ="login-form ">
9
-
10
- {% if email_updated == "true" %}
11
- < div class ="alert alert-success " role ="alert ">
12
- Your email address has been successfully updated. Please login with your new email address.
13
- </ div >
14
- {% endif %}
15
-
16
9
< form method ="POST " action ="{{ url_for('login') }} " class ="needs-validation " novalidate >
17
10
<!-- Email Input -->
18
11
< div class ="mb-3 ">
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ <h1 class="mb-4">User Profile</h1>
14
14
</ div >
15
15
{% endif %}
16
16
17
+ {% if email_updated == "true" %}
18
+ < div class ="alert alert-success " role ="alert ">
19
+ Your email address has been successfully updated.
20
+ </ div >
21
+ {% endif %}
22
+
17
23
<!-- Basic Information -->
18
24
< div class ="card mb-4 " id ="basic-info ">
19
25
< div class ="card-header ">
You can’t perform that action at this time.
0 commit comments