Skip to content

Commit

Permalink
fix: Merge welcome and email verification mail (#7399)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal authored Oct 30, 2020
1 parent a1ea1d0 commit 7c246ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
11 changes: 8 additions & 3 deletions app/api/helpers/system_mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,15 @@
},
USER_REGISTER: {
'recipient': 'User',
'subject': 'Account Created on {app_name}',
'subject': 'Welcome to {app_name}. Please verify your account',
'message': (
"Your Account Has Been Created! Congratulations!"
+ "<br/> Your login: {email}"
"Hello,"
"<br/><br/>Your account has been created on {app_name}. Congratulations!"
"<br/><br/>Your login is: {email}"
"<br/><br/>Please visit the following link to verify your email: {link}"
"<br/><br/>Thank You,"
"<br/><br/>{app_name} Team"
"<br/>{frontend_url}"
),
},
USER_REGISTER_WITH_PASSWORD: {
Expand Down
46 changes: 17 additions & 29 deletions app/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
from app.api.helpers.db import get_count, safe_query_kwargs
from app.api.helpers.errors import ConflictError, ForbiddenError, UnprocessableEntityError
from app.api.helpers.files import make_frontend_url
from app.api.helpers.mail import (
send_email_change_user_email,
send_email_confirmation,
send_email_with_action,
)
from app.api.helpers.mail import send_email_change_user_email, send_email_with_action
from app.api.helpers.permission_manager import has_access
from app.api.helpers.permissions import is_user_itself
from app.api.helpers.user import (
Expand All @@ -31,7 +27,7 @@
from app.models.event import Event
from app.models.event_invoice import EventInvoice
from app.models.feedback import Feedback
from app.models.mail import PASSWORD_RESET_AND_VERIFY, USER_REGISTER_WITH_PASSWORD
from app.models.mail import USER_REGISTER
from app.models.notification import Notification
from app.models.order import Order
from app.models.session import Session
Expand Down Expand Up @@ -90,29 +86,21 @@ def after_create_object(self, user, data, view_kwargs):
:return:
"""

if user.was_registered_with_order:
link = make_frontend_url('/reset-password', {'token': user.reset_password})
send_email_with_action(
user,
PASSWORD_RESET_AND_VERIFY,
app_name=get_settings()['app_name'],
email=user.email,
link=link,
)
else:
s = get_serializer()
hash = str(
base64.b64encode(str(s.dumps([user.email, str_generator()])).encode()),
'utf-8',
)
link = make_frontend_url('/verify', {'token': hash})
send_email_with_action(
user,
USER_REGISTER_WITH_PASSWORD,
app_name=get_settings()['app_name'],
email=user.email,
)
send_email_confirmation(user.email, link)
s = get_serializer()
hash = str(
base64.b64encode(str(s.dumps([user.email, str_generator()])).encode()),
'utf-8',
)
link = make_frontend_url('/verify', {'token': hash})
settings = get_settings()
send_email_with_action(
user,
USER_REGISTER,
app_name=settings['app_name'],
email=user.email,
link=link,
frontend_url=settings['frontend_url'],
)
# TODO Handle in a celery task
# if data.get('original_image_url'):
# try:
Expand Down

0 comments on commit 7c246ed

Please sign in to comment.