diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e910649..8edc0d6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/backend/backlog_app/servicies/authentification/user_manager.py b/backend/backlog_app/servicies/authentification/user_manager.py index d0a9768..57aba56 100644 --- a/backend/backlog_app/servicies/authentification/user_manager.py +++ b/backend/backlog_app/servicies/authentification/user_manager.py @@ -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, @@ -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( @@ -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 diff --git a/backend/backlog_app/tasks/email_task.py b/backend/backlog_app/tasks/email_task.py index 6a46bfb..6942b09 100644 --- a/backend/backlog_app/tasks/email_task.py +++ b/backend/backlog_app/tasks/email_task.py @@ -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) @@ -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) @@ -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, } @@ -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, diff --git a/backend/backlog_app/templates/email-forgot/password-reset-confirmed.html b/backend/backlog_app/templates/email-forgot/password-reset-confirmed.html index a54c383..5c005de 100644 --- a/backend/backlog_app/templates/email-forgot/password-reset-confirmed.html +++ b/backend/backlog_app/templates/email-forgot/password-reset-confirmed.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block title %} - Password successfully changed + Пароль успешно изменён {% endblock %} {% block main %} @@ -17,7 +17,7 @@

- 🔑 Password changed successfully + 🔑 Пароль успешно изменён

@@ -25,14 +25,14 @@

- Hello {{ user_email }}, + Здравствуйте! - Your password has been successfully updated. You can now use your new password to log in to your account. + Ваш пароль был успешно обновлён. Теперь вы можете войти в аккаунт с новым паролем. @@ -44,7 +44,7 @@

color:#ffffff;background-color:#16a34a; text-decoration:none;border-radius:8px; font-weight:600;"> - Log in to your account + Войти в аккаунт @@ -52,7 +52,8 @@

- If you did not perform this action, please contact our support immediately. + Если вы не выполняли это действие, немедленно свяжитесь со службой поддержки: + admin@backlog-movie.ru @@ -60,7 +61,7 @@

- This is an automated message. Please do not reply to this email. + Это автоматическое сообщение. Пожалуйста, не отвечайте на это письмо. diff --git a/backend/backlog_app/templates/email-forgot/password-reset-request.html b/backend/backlog_app/templates/email-forgot/password-reset-request.html index 553f684..80b71ef 100644 --- a/backend/backlog_app/templates/email-forgot/password-reset-request.html +++ b/backend/backlog_app/templates/email-forgot/password-reset-request.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block title %} - Password reset request + Сброс пароля {% endblock %} {% block main %} @@ -17,7 +17,7 @@

- 🔐 Password reset request + 🔐 Запрос на сброс пароля

@@ -25,15 +25,15 @@

- Hello {{ user_email }}, + Здравствуйте! - We received a request to reset your account password. - Click the button below to set a new password. + Мы получили запрос на сброс пароля от вашего аккаунта. + Нажмите на кнопку ниже, чтобы задать новый пароль. @@ -45,7 +45,7 @@

color:#ffffff;background-color:#2563eb; text-decoration:none;border-radius:8px; font-weight:600;"> - Reset Password + Сбросить пароль @@ -53,7 +53,7 @@

- If the button doesn’t work, copy and paste this link into your browser: + Если кнопка не работает, скопируйте и вставьте эту ссылку в браузер:
{{ reset_link }} @@ -64,8 +64,8 @@

- If you did not request a password reset, please ignore this email. - Your password will remain unchanged. + Если вы не запрашивали сброс пароля, просто проигнорируйте это письмо. + Ваш пароль останется без изменений. @@ -73,7 +73,7 @@

- This link will expire in {{ expires_in | default("24 hours") }}. + Ссылка действительна в течение {{ expires_in | default("24 часов") }}. diff --git a/backend/backlog_app/templates/email-verify/email-verified.html b/backend/backlog_app/templates/email-verify/email-verified.html index df43ffd..4289f5f 100644 --- a/backend/backlog_app/templates/email-verify/email-verified.html +++ b/backend/backlog_app/templates/email-verify/email-verified.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block title %} - Email confirmed + Почта подтверждена {% endblock %} {% block main %} @@ -15,7 +15,7 @@

- ✅ Email successfully confirmed + ✅ Почта успешно подтверждена

@@ -23,15 +23,15 @@

- Hello {{ user_email }}, + Здравствуйте! - Your email address has been successfully verified. - Your account is now fully activated and ready to use. + Ваш адрес электронной почты успешно подтверждён. + Ваш аккаунт полностью активирован и готов к использованию. @@ -43,7 +43,7 @@

color:#ffffff;background-color:#16a34a; text-decoration:none;border-radius:8px; font-weight:600;"> - Go to Login + Войти в аккаунт @@ -51,7 +51,8 @@

- If you did not perform this action, please contact support immediately. + Если вы не выполняли это действие, немедленно свяжитесь со службой поддержки:
+ admin@backlog-movie.ru diff --git a/backend/backlog_app/templates/email-verify/verification-request.html b/backend/backlog_app/templates/email-verify/verification-request.html index 8f33409..f0a6466 100644 --- a/backend/backlog_app/templates/email-verify/verification-request.html +++ b/backend/backlog_app/templates/email-verify/verification-request.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block title %} - Email verification + Подтверждение почты {% endblock %} {% block main %} @@ -15,7 +15,7 @@

- Confirm your email + Подтвердите вашу почту

@@ -23,14 +23,14 @@

- Hello {{ user_email }}, + Здравствуйте! - Thanks for registering. Please confirm your email address by clicking the button below. + Спасибо за регистрацию. Пожалуйста, подтвердите ваш адрес электронной почты, нажав на кнопку ниже. @@ -42,7 +42,7 @@

color:#ffffff;background-color:#2563eb; text-decoration:none;border-radius:8px; font-weight:600;"> - Verify Email + Подтвердить почту @@ -50,7 +50,7 @@

- If the button doesn’t work, copy and paste this link into your browser: + Если кнопка не работает, скопируйте и вставьте эту ссылку в браузер:
{{ verification_link }} @@ -61,8 +61,9 @@

- This link will expire in 24 hours.
- If you didn’t request this, you can safely ignore this email. + Ссылка действительна в течение 24 часов.
+ Если вы не запрашивали это письмо, просто проигнорируйте его или свяжитесь со службой поддержки:
+
admin@backlog-movie.ru