-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#620 User workflow: create new account (#142)
* saving * addes todos * read function for sending email from settings * use system sender id * read sms sender for system notifications * throttlinh for system notifications * check code * delete cookie after login, show errors * pr fix
- Loading branch information
1 parent
ec32db9
commit 69efef6
Showing
14 changed files
with
332 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
django_project_base/account/service/register_user_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.conf import settings | ||
from django.core.cache import cache | ||
from django.utils.translation import gettext as __ | ||
from natural.date import compress | ||
from rest_framework.request import Request | ||
|
||
from django_project_base.notifications.email_notification import SystemEMailNotification | ||
from django_project_base.notifications.models import DjangoProjectBaseMessage | ||
|
||
|
||
def send_register_verification_email_notification( | ||
request: Request, | ||
user, | ||
) -> None: | ||
if (flow_id := request.COOKIES.get("register-flow")) and (code := cache.get(flow_id)): | ||
SystemEMailNotification( | ||
message=DjangoProjectBaseMessage( | ||
subject=f"{__('Account confirmation for')} {request.META['HTTP_HOST']}", | ||
body=f"{__('You or someone acting as you registered an account at')} " | ||
f"{request.META['HTTP_HOST']}. " | ||
f"\n\n{__('Your verification code is')}: " | ||
f"{code} \n\n {__('Code is valid for')} {compress(settings.CONFIRMATION_CODE_TIMEOUT)}.\n\n" | ||
f"{__('If this was not you or it was unintentional, you may safely ignore this message.')}", | ||
footer="", | ||
content_type=DjangoProjectBaseMessage.PLAIN_TEXT, | ||
), | ||
recipients=[user.pk], | ||
user=user.pk, | ||
).send() | ||
cache.set(code, user, timeout=settings.CONFIRMATION_CODE_TIMEOUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.