|
23 | 23 | tags=["user"], |
24 | 24 | ) |
25 | 25 |
|
| 26 | +style = """<style> |
| 27 | + body { |
| 28 | + background-color: #f8f9fa; |
| 29 | + font-family: 'Roboto', sans-serif; |
| 30 | + margin: 0; |
| 31 | + padding: 0; |
| 32 | + color: #212121; |
| 33 | + } |
| 34 | + .container { |
| 35 | + max-width: 600px; |
| 36 | + margin: 2rem auto; |
| 37 | + background: #fff; |
| 38 | + border-radius: 8px; |
| 39 | + box-shadow: 0 4px 12px rgba(0,0,0,0.08); |
| 40 | + padding: 2rem; |
| 41 | + } |
| 42 | + .header { |
| 43 | + text-align: center; |
| 44 | + margin-bottom: 1rem; |
| 45 | + } |
| 46 | + .title { |
| 47 | + font-size: 1.5rem; |
| 48 | + font-weight: 500; |
| 49 | + } |
| 50 | + .content { |
| 51 | + margin: 1rem 0; |
| 52 | + line-height: 1.6; |
| 53 | + } |
| 54 | + .password-box { |
| 55 | + background-color: #e3f2fd; |
| 56 | + padding: 1rem; |
| 57 | + font-size: 1.25rem; |
| 58 | + font-weight: bold; |
| 59 | + border-radius: 6px; |
| 60 | + text-align: center; |
| 61 | + color: #0d47a1; |
| 62 | + letter-spacing: 0.5px; |
| 63 | + } |
| 64 | + .btn { |
| 65 | + display: inline-block; |
| 66 | + background-color: #1976d2; |
| 67 | + color: #fff !important; |
| 68 | + padding: 0.75rem 1.5rem; |
| 69 | + text-decoration: none; |
| 70 | + border-radius: 24px; |
| 71 | + font-weight: 500; |
| 72 | + transition: background 0.3s ease; |
| 73 | + } |
| 74 | + .btn:hover { |
| 75 | + background-color: #1565c0; |
| 76 | + } |
| 77 | + .footer { |
| 78 | + text-align: center; |
| 79 | + font-size: 0.875rem; |
| 80 | + margin-top: 2rem; |
| 81 | + color: #666; |
| 82 | + } |
| 83 | + .icon-links { |
| 84 | + margin-top: 1rem; |
| 85 | + text-align: center; |
| 86 | + } |
| 87 | + .icon-links a { |
| 88 | + margin: 0 0.5rem; |
| 89 | + display: inline-block; |
| 90 | + text-decoration: none; |
| 91 | + } |
| 92 | + .icon-links img { |
| 93 | + width: 24px; |
| 94 | + height: 24px; |
| 95 | + vertical-align: middle; |
| 96 | + filter: grayscale(100%); |
| 97 | + transition: filter 0.3s; |
| 98 | + } |
| 99 | + .icon-links img:hover { |
| 100 | + filter: grayscale(0%); |
| 101 | + } |
| 102 | + </style> |
| 103 | +""" |
| 104 | + |
26 | 105 | SECRET_KEY_JWT = os.getenv("SECRET_KEY_JWT") or "$2b$12$zqt9Rgv1PzORjG5ghJSb6OSdYrt7f7cLc38a21DgX/DMyqt80AUCi" |
27 | 106 | ALGORITHM = "HS256" |
28 | 107 |
|
@@ -84,7 +163,44 @@ async def register_user( |
84 | 163 | await EmailService().send_email( |
85 | 164 | to=[user_data.email], |
86 | 165 | subject=f"[Suppl-AI] Registrazione utente", |
87 | | - body=f"Benvenuto in Suppl-AI!\nEcco la tua password temporanea\n\n{password}\n\n Accedi e cambiala subito!", |
| 166 | + body=f""" |
| 167 | + <!DOCTYPE html> |
| 168 | + <html lang="it"> |
| 169 | + <head> |
| 170 | + <meta charset="UTF-8" /> |
| 171 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 172 | + <title>Registrazione utente</title> |
| 173 | + {style} |
| 174 | + </head> |
| 175 | + <body> |
| 176 | + <div class="container"> |
| 177 | + <div class="header"> |
| 178 | + <div class="title" style="font-size: 2rem; font-weight: 700; color: #1976d2;">SUPPL-AI</div> |
| 179 | + </div> |
| 180 | + <div class="content"> |
| 181 | + <p><strong>Benvenuto in Suppl-AI!</strong></p> |
| 182 | + <p>Ecco la tua password temporanea:</p> |
| 183 | + <div class="password-box">{password}</div> |
| 184 | + <p>Accedi e cambiala subito!</p> |
| 185 | + </div> |
| 186 | +
|
| 187 | + <div class="icon-links"> |
| 188 | + <a href="https://codehex16.github.io/" title="Sito Web"> |
| 189 | + <img src="https://img.icons8.com/ios-filled/50/000000/domain.png" alt="Sito"> |
| 190 | + </a> |
| 191 | + <a href="https://github.com/codehex16" title="GitHub"> |
| 192 | + <img src="https://img.icons8.com/ios-filled/50/000000/github.png" alt="GitHub"> |
| 193 | + </a> |
| 194 | + </div> |
| 195 | +
|
| 196 | + <div class="footer"> |
| 197 | + Questo progetto è realizzato da <strong>CodeHex16</strong>, gruppo 16 del Progetto di SWE dell'Università degli Studi di Padova. |
| 198 | + </div> |
| 199 | + </div> |
| 200 | + </body> |
| 201 | + </html> |
| 202 | + """ |
| 203 | + # body=f"Benvenuto in Suppl-AI!\nEcco la tua password temporanea\n\n{password}\n\n Accedi e cambiala subito!", |
88 | 204 | ) |
89 | 205 | except Exception as e: |
90 | 206 | raise HTTPException( |
@@ -362,7 +478,44 @@ async def reset_password( |
362 | 478 | await EmailService().send_email( |
363 | 479 | to=[user.get("_id")], |
364 | 480 | subject="[Suppl-AI] Password Reset", |
365 | | - body=f"Ciao {user.get('name')},\n\nEcco la tua nuova password temporanea:\n\n{password}\n\nAccedi e cambiala subito!", |
| 481 | + body=f""" |
| 482 | + <!DOCTYPE html> |
| 483 | + <html lang="it"> |
| 484 | + <head> |
| 485 | + <meta charset="UTF-8" /> |
| 486 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 487 | + <title>Password Reset</title> |
| 488 | + {style} |
| 489 | + </head> |
| 490 | + <body> |
| 491 | + <div class="container"> |
| 492 | + <div class="header"> |
| 493 | + <div class="title" style="font-size: 2rem; font-weight: 700; color: #1976d2;">SUPPL-AI</div> |
| 494 | + <div class="title">Ciao {html.escape(user.get('name'))},</div> |
| 495 | + </div> |
| 496 | + <div class="content"> |
| 497 | + Ecco la tua nuova password temporanea: |
| 498 | + <div class="password-box">{password}</div> |
| 499 | + <p>Accedi e cambiala subito per mantenere il tuo account sicuro.</p> |
| 500 | + </div> |
| 501 | +
|
| 502 | + <div class="icon-links"> |
| 503 | + <a href="https://codehex16.github.io/" title="Sito Web"> |
| 504 | + <img src="https://img.icons8.com/ios-filled/50/000000/domain.png" alt="Sito"> |
| 505 | + </a> |
| 506 | + <a href="https://github.com/codehex16" title="GitHub"> |
| 507 | + <img src="https://img.icons8.com/ios-filled/50/000000/github.png" alt="GitHub"> |
| 508 | + </a> |
| 509 | + </div> |
| 510 | +
|
| 511 | + <div class="footer"> |
| 512 | + Questo progetto è realizzato da <strong>CodeHex16</strong>, gruppo 16 del Progetto di SWE dell'Università degli Studi di Padova. |
| 513 | + </div> |
| 514 | + </div> |
| 515 | + </body> |
| 516 | + </html> |
| 517 | + """ |
| 518 | + # body=f"Ciao {user.get('name')},\n\nEcco la tua nuova password temporanea:\n\n{password}\n\nAccedi e cambiala subito!", |
366 | 519 | ) |
367 | 520 | except Exception as e: |
368 | 521 | # raise HTTPException( |
|
0 commit comments