Тест кода

This commit is contained in:
urec56 2024-08-27 19:11:18 +04:00
parent ab989c6020
commit fe3d283e3c
2 changed files with 70 additions and 61 deletions

View file

@ -1,3 +1,4 @@
import logging
from datetime import timedelta from datetime import timedelta
from pydantic import ValidationError from pydantic import ValidationError
@ -75,6 +76,7 @@ class UserService:
verification_code = await redis.get_value(key=f"user_verification_code: {user.id}") verification_code = await redis.get_value(key=f"user_verification_code: {user.id}")
except AttributeError: except AttributeError:
raise WrongCodeException raise WrongCodeException
logging.warning(verification_code)
if verification_code != confirmation_code: if verification_code != confirmation_code:
raise WrongCodeException raise WrongCodeException
async with uow: async with uow:

View file

@ -16,80 +16,87 @@ def create_registration_confirmation_template(
email.set_content( email.set_content(
f""" f"""
<!DOCTYPE html> <html lang="en">
<html lang="en"> <head>
<head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@200&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@200&display=swap" rel="stylesheet">
<title>Submiting</title> <title>Submiting</title>
</head> </head>
<body> <body style="margin: 0;
<body style=" padding: 0;">
width:99%; <table cellpadding="10" cellspacing="0" width="100%" style="background-color: #101010;">
height:99%; <tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center">
<div style="
display: flex;
flex-direction: column;
justify-content:space-around;
align-items: center;
text-align:center;
display: flex; max-width:500px;
flex-direction:column; min-width:350px;
align-items: center; aspect-ratio: 1 / 1.34;
background-color:#101010; border: 1px solid transparent;
background:
font-family: 'Comfortaa';
font-weight: 200;
font-style: normal;
font-stretch: normal;
font-optical-sizing: auto;
">
<div style="
display: flex;
flex-direction: column;
justify-content:space-around;
align-items: center;
text-align:center;
height:500px;
aspect-ratio: 1 / 1.44;
border: 1px solid transparent;
background:
linear-gradient(#101010, #101010) padding-box,
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
border-radius: 15px;
">
<h1 style="color:white;">Код подтверждения, {username}</h1>
<div style="
border: 1px solid transparent;
background:
linear-gradient(#101010, #101010) padding-box, linear-gradient(#101010, #101010) padding-box,
linear-gradient(to bottom, #3C53FF, #7734AA) border-box; linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
border-radius: 15px; border-radius: 12px;
">
<h2 style="color:white; padding:0 5px 0 5px;">{confirmation_code}</h2> font-family: comfortaa;
</div> ">
<h1 style="color:white;">или</h1> <h1 style="color:white; font-family: comfortaa;">Код подтверждения для сладкого {username}</h1>
<a href="{confirmation_link}" style=" <h2 style="
border: 1px solid transparent; padding: 10px;
background: color: white;
linear-gradient(#101010, #101010) padding-box, border: 1px solid transparent;
linear-gradient(to bottom, #3C53FF, #7734AA) border-box; background:
border-radius: 15px; linear-gradient(#101010, #101010) padding-box,
text-decoration: none; linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
"> border-radius: 12px;
<h2 style="color: white; padding:0 5px 0 5px;">перейдите по ссылке</h2> font-family: comfortaa;
</a> ">{confirmation_code}</h2>
</div>
<h1 style="color:white;">или</h1>
<a href="{confirmation_link}" style="
padding: 10px;
color: white;
border: 1px solid transparent;
background:
linear-gradient(#101010, #101010) padding-box,
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
border-radius: 12px;
text-decoration: none;
font-family: comfortaa;
font-size:1.5em;
">перейдите по ссылке
</a>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</body> </body>
</body> </html>
</html>
""", """,
subtype="html", subtype="html",
) )
@ -165,7 +172,7 @@ def create_data_change_confirmation_email(username: str, email_to: EmailStr, _:
</body> </body>
</body> </body>
</html> </html>
""", """,
subtype="html", subtype="html",
) )
return email return email
@ -230,7 +237,7 @@ def create_data_change_email(username: str, email_to: EmailStr):
</body> </body>
</body> </body>
</html> </html>
""", """,
subtype="html", subtype="html",
) )
return email return email