diff --git a/id.saladeaula.digital/app/routes/register.py b/id.saladeaula.digital/app/routes/register.py
index bbf2221..f73206a 100644
--- a/id.saladeaula.digital/app/routes/register.py
+++ b/id.saladeaula.digital/app/routes/register.py
@@ -129,6 +129,17 @@ def _create_user(*, user: User, password: str):
'created_at': now_,
}
)
+ transact.put(
+ item={
+ 'id': user.id,
+ 'sk': f'EMAIL_VERIFICATION#{uuid4()}',
+ 'welcome': True,
+ 'name': user.name,
+ 'email': user.email,
+ 'ttl': ttl(start_dt=now_, days=30),
+ 'created_at': now_,
+ }
+ )
transact.put(
item={
'id': user.id,
diff --git a/users-events/app/events/send_welcome_email.py b/users-events/app/events/send_welcome_email.py
index 736c596..7dbe773 100644
--- a/users-events/app/events/send_welcome_email.py
+++ b/users-events/app/events/send_welcome_email.py
@@ -10,40 +10,46 @@ from layercake.strutils import first_word
from boto3clients import sesv2_client
from config import EMAIL_SENDER
-SUBJECT = '{first_name} você foi cadastrado na EDUSEG®'
-MESSAGE = """
-Oi {first_name}, tudo bem?
-
-Sua conta foi criada na EDUSEG pela empresa {org_name}.
-
-
-👉 Clique aqui para fazer seu primeiro acesso
-
-"""
-
logger = Logger(__name__)
@event_source(data_class=EventBridgeEvent)
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
new_image = event.detail['new_image']
- # Key pattern `EMAIL_VERIFICATION#{hash}`
- *_, hash = new_image['sk'].split('#')
+ # Key pattern `EMAIL_VERIFICATION#{code}`
+ *_, code = new_image['sk'].split('#')
first_name = first_word(new_image['name'])
+ org_name = new_image.get('org_name')
+
+ if isinstance(org_name, str):
+ subject = f'{first_name}, você foi cadastrado na EDUSEG®'
+ body = f"""
+ Oi {first_name}, tudo bem?
+
+ Sua conta foi criada na EDUSEG pela empresa {org_name}.
+
+
+ 👉 Clique aqui para fazer seu primeiro acesso
+
+ """
+ else:
+ subject = f'{first_name}, sua conta na EDUSEG® foi criada'
+ body = f"""
+ Oi {first_name}, tudo bem?
+
+ Sua conta na EDUSEG® foi criada com sucesso.
+
+
+ 👉 Clique aqui para verificar endereço de email
+
+ """
emailmsg = Message(
from_=EMAIL_SENDER,
to=(new_image['name'], new_image['email']),
- subject=SUBJECT.format(first_name=first_name),
- )
- emailmsg.add_alternative(
- MESSAGE.format(
- user_id=new_image['id'],
- first_name=first_name,
- org_name=new_image.get('org_name'),
- code=hash,
- )
+ subject=subject,
)
+ emailmsg.add_alternative(body)
try:
sesv2_client.send_email(
diff --git a/users-events/template.yaml b/users-events/template.yaml
index 8dd716f..bf3137a 100644
--- a/users-events/template.yaml
+++ b/users-events/template.yaml
@@ -190,8 +190,6 @@ Resources:
- prefix: EMAIL_VERIFICATION#
welcome:
- exists: true
- org_name:
- - exists: true
EventSendVerificationEmailFunction:
Type: AWS::Serverless::Function