Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@ repos:
hooks:
- id: black
files: ^backend/
args:
- --check
- --diff

- repo: https://github.com/pycqa/isort
rev: 7.0.0
hooks:
- id: isort
files: ^backend/
args:
- --check-only
- --diff
11 changes: 7 additions & 4 deletions backend/backlog_app/servicies/authentification/user_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ async def on_after_request_verify(
token,
)

origin = request.headers.get("origin") or settings.FRONTEND_URL
origin = request.headers.get("origin")
logger.debug("origin url: %s", origin)

verification_link = f"{origin}/verify?token={token}"
verification_link = f"{origin}/email-verified?token={token}"
await email_task.send_verification_email.kiq(
user_email=user.email,
verification_link=verification_link,
Expand All @@ -43,8 +43,11 @@ async def on_after_request_verify(
async def on_after_verify(self, user: User, request: Optional["Request"] = None):
logger.warning("User <%s> has been verified", user.id)

origin = request.headers.get("origin")
login_link = f"{origin}/login"

await email_task.send_email_confirmed.kiq(
user_email=user.email,
user_email=user.email, login_link=login_link
)

async def on_after_login(
Expand All @@ -64,7 +67,7 @@ async def on_after_forgot_password(
token,
self.reset_password_token_lifetime_seconds,
)
origin = request.headers.get("origin") or settings.FRONTEND_URL
origin = request.headers.get("origin")
reset_link = f"{origin}/reset-password?token={token}"
token_lifetime = format_seconds_for_email(
self.reset_password_token_lifetime_seconds
Expand Down
68 changes: 35 additions & 33 deletions backend/backlog_app/tasks/email_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ async def send_verification_email(
user_email: str,
verification_link: str,
) -> None:
subject = "Confirm your email"
subject = "Подтверждение регистрации на сайте backlog-movie.ru"

plain_content = dedent(f"""\
Dear {user_email},
Please verify your email for site.com at {verification_link}.
plain_content = dedent(
f"""\
Здравствуйте!
Пожалуйста, подтвердите ваш адрес электронной почты на сайте backlog-movie.ru, перейдя по ссылке: {verification_link}

Your site admin,
2025
""")
Администрация backlog-movie.ru
"""
)
template = templates.get_template("email-verify/verification-request.html")
context = {
"user_email": user_email,
"verification_link": verification_link,
}
html_content = template.render(context)
Expand All @@ -37,17 +37,20 @@ async def send_verification_email(
@broker.task
async def send_email_confirmed(
user_email: str,
login_link: str,
):
subject = "Email Confirmed"
subject = "Адрес электронной почты успешно подтверждён"

plain_content = dedent(
f"""\
Здравствуйте!
Ваш адрес электронной почты успешно подтверждён.

plain_content = dedent(f"""\
Dear {user_email},
Your email has been confirmed.
Your site admin,
2025""")
Администрация backlog-movie.ru"""
)
template = templates.get_template("email-verify/email-verified.html")
context = {
"user_email": user_email,
"login_link": login_link,
}
html_content = template.render(context)

Expand All @@ -63,16 +66,16 @@ async def send_email_confirmed(
async def send_email_forgot_password(
user_email: str, reset_link: str, token_lifetime: str
):
subject = "Request for change password"
plain_content = dedent(f"""\
Dear {user_email},
We get your request for change password.
Link for change: {reset_link}
Your site admin,
2025""")
subject = "Запрос на сброс пароля на сайте backlog-movie.ru"
plain_content = dedent(
f"""\
Здравствуйте!
Мы получили запрос на сброс пароля. Перейдите по ссылке, чтобы задать новый пароль: {reset_link}

Администрация backlog-movie.ru"""
)
template = templates.get_template("email-forgot/password-reset-request.html")
context = {
"user_email": user_email,
"reset_link": reset_link,
"expires_in": token_lifetime,
}
Expand All @@ -90,17 +93,16 @@ async def send_email_forgot_password(
async def send_email_forgot_password_confirmed(
user_email: str,
):
subject = "Password reset request confirmed"
plain_content = dedent(f"""\
Dear {user_email},
Your password reset request has been confirmed.
Your site admin,
2025""")
subject = "Пароль был успешно изменён"
plain_content = dedent(
f"""\
Здравствуйте!
Ваш пароль был успешно изменён.

Администрация backlog-movie.ru"""
)
template = templates.get_template("email-forgot/password-reset-confirmed.html")
context = {
"user_email": user_email,
}
html_content = template.render(context)
html_content = template.render()

await send_email(
recipient=user_email,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}

{% block title %}
Password successfully changed
Пароль успешно изменён
{% endblock %}

{% block main %}
Expand All @@ -17,22 +17,22 @@
<tr>
<td align="center" style="padding-bottom:30px;">
<h1 style="margin:0;font-size:24px;font-weight:600;color:#111827;">
🔑 Password changed successfully
🔑 Пароль успешно изменён
</h1>
</td>
</tr>

<!-- Greeting -->
<tr>
<td style="font-size:16px;line-height:1.6;padding-bottom:20px;">
Hello <strong>{{ user_email }}</strong>,
Здравствуйте!
</td>
</tr>

<!-- Message -->
<tr>
<td style="font-size:16px;line-height:1.6;padding-bottom:30px;color:#4b5563;">
Your password has been successfully updated. You can now use your new password to log in to your account.
Ваш пароль был успешно обновлён. Теперь вы можете войти в аккаунт с новым паролем.
</td>
</tr>

Expand All @@ -44,23 +44,24 @@ <h1 style="margin:0;font-size:24px;font-weight:600;color:#111827;">
color:#ffffff;background-color:#16a34a;
text-decoration:none;border-radius:8px;
font-weight:600;">
Log in to your account
Войти в аккаунт
</a>
</td>
</tr>

<!-- Security Notice -->
<tr>
<td style="font-size:14px;line-height:1.6;color:#b91c1c;padding-bottom:20px;">
If you did not perform this action, please contact our support immediately.
Если вы не выполняли это действие, немедленно свяжитесь со службой поддержки:
<a href="mailto:admin@backlog-movie.ru" style="color:#b91c1c;">admin@backlog-movie.ru</a>
</td>
</tr>

<!-- Footer -->
<tr>
<td style="font-size:13px;color:#9ca3af;text-align:center;
padding-top:30px;border-top:1px solid #e5e7eb;">
This is an automated message. Please do not reply to this email.
Это автоматическое сообщение. Пожалуйста, не отвечайте на это письмо.
</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}

{% block title %}
Password reset request
Сброс пароля
{% endblock %}

{% block main %}
Expand All @@ -17,23 +17,23 @@
<tr>
<td align="center" style="padding-bottom:30px;">
<h1 style="margin:0;font-size:24px;font-weight:600;color:#111827;">
🔐 Password reset request
🔐 Запрос на сброс пароля
</h1>
</td>
</tr>

<!-- Greeting -->
<tr>
<td style="font-size:16px;line-height:1.6;padding-bottom:20px;">
Hello <strong>{{ user_email }}</strong>,
Здравствуйте!
</td>
</tr>

<!-- Message -->
<tr>
<td style="font-size:16px;line-height:1.6;padding-bottom:30px;color:#4b5563;">
We received a request to reset your account password.
Click the button below to set a new password.
Мы получили запрос на сброс пароля от вашего аккаунта.
Нажмите на кнопку ниже, чтобы задать новый пароль.
</td>
</tr>

Expand All @@ -45,15 +45,15 @@ <h1 style="margin:0;font-size:24px;font-weight:600;color:#111827;">
color:#ffffff;background-color:#2563eb;
text-decoration:none;border-radius:8px;
font-weight:600;">
Reset Password
Сбросить пароль
</a>
</td>
</tr>

<!-- Fallback Link -->
<tr>
<td style="font-size:14px;line-height:1.6;color:#6b7280;padding-bottom:20px;">
If the button doesn’t work, copy and paste this link into your browser:
Если кнопка не работает, скопируйте и вставьте эту ссылку в браузер:
<br>
<a href="{{ reset_link }}" style="color:#2563eb;word-break:break-all;">
{{ reset_link }}
Expand All @@ -64,16 +64,16 @@ <h1 style="margin:0;font-size:24px;font-weight:600;color:#111827;">
<!-- Security Notice -->
<tr>
<td style="font-size:14px;line-height:1.6;color:#b91c1c;padding-bottom:20px;">
If you did not request a password reset, please ignore this email.
Your password will remain unchanged.
Если вы не запрашивали сброс пароля, просто проигнорируйте это письмо.
Ваш пароль останется без изменений.
</td>
</tr>

<!-- Footer -->
<tr>
<td style="font-size:13px;color:#9ca3af;text-align:center;
padding-top:30px;border-top:1px solid #e5e7eb;">
This link will expire in {{ expires_in | default("24 hours") }}.
Ссылка действительна в течение {{ expires_in | default("24 часов") }}.
</td>
</tr>

Expand Down
15 changes: 8 additions & 7 deletions backend/backlog_app/templates/email-verify/email-verified.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}

{% block title %}
Email confirmed
Почта подтверждена
{% endblock %}

{% block main %}
Expand All @@ -15,23 +15,23 @@
<tr>
<td align="center" style="padding-bottom:30px;">
<h1 style="margin:0;font-size:24px;font-weight:600;color:#111827;">
Email successfully confirmed
Почта успешно подтверждена
</h1>
</td>
</tr>

<!-- Greeting -->
<tr>
<td style="font-size:16px;line-height:1.6;padding-bottom:20px;">
Hello <strong>{{ user_email }}</strong>,
Здравствуйте!
</td>
</tr>

<!-- Message -->
<tr>
<td style="font-size:16px;line-height:1.6;padding-bottom:30px;color:#4b5563;">
Your email address has been successfully verified.
Your account is now fully activated and ready to use.
Ваш адрес электронной почты успешно подтверждён.
Ваш аккаунт полностью активирован и готов к использованию.
</td>
</tr>

Expand All @@ -43,15 +43,16 @@ <h1 style="margin:0;font-size:24px;font-weight:600;color:#111827;">
color:#ffffff;background-color:#16a34a;
text-decoration:none;border-radius:8px;
font-weight:600;">
Go to Login
Войти в аккаунт
</a>
</td>
</tr>

<!-- Footer -->
<tr>
<td style="font-size:13px;color:#9ca3af;text-align:center;padding-top:30px;border-top:1px solid #e5e7eb;">
If you did not perform this action, please contact support immediately.
Если вы не выполняли это действие, немедленно свяжитесь со службой поддержки:<br>
<a href="mailto:admin@backlog-movie.ru" style="color:#9ca3af;">admin@backlog-movie.ru</a>
</td>
</tr>

Expand Down
Loading
Loading