update
This commit is contained in:
@@ -129,6 +129,17 @@ def _create_user(*, user: User, password: str):
|
|||||||
'created_at': now_,
|
'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(
|
transact.put(
|
||||||
item={
|
item={
|
||||||
'id': user.id,
|
'id': user.id,
|
||||||
|
|||||||
@@ -10,40 +10,46 @@ from layercake.strutils import first_word
|
|||||||
from boto3clients import sesv2_client
|
from boto3clients import sesv2_client
|
||||||
from config import EMAIL_SENDER
|
from config import EMAIL_SENDER
|
||||||
|
|
||||||
SUBJECT = '{first_name} você foi cadastrado na EDUSEG®'
|
|
||||||
MESSAGE = """
|
|
||||||
Oi {first_name}, tudo bem?<br/><br/>
|
|
||||||
|
|
||||||
Sua conta foi criada na EDUSEG pela empresa <b>{org_name}</b>.<br/><br/>
|
|
||||||
|
|
||||||
<a href="https://id.saladeaula.digital/register">
|
|
||||||
👉 Clique aqui para fazer seu primeiro acesso
|
|
||||||
</a>
|
|
||||||
"""
|
|
||||||
|
|
||||||
logger = Logger(__name__)
|
logger = Logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@event_source(data_class=EventBridgeEvent)
|
@event_source(data_class=EventBridgeEvent)
|
||||||
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||||
new_image = event.detail['new_image']
|
new_image = event.detail['new_image']
|
||||||
# Key pattern `EMAIL_VERIFICATION#{hash}`
|
# Key pattern `EMAIL_VERIFICATION#{code}`
|
||||||
*_, hash = new_image['sk'].split('#')
|
*_, code = new_image['sk'].split('#')
|
||||||
first_name = first_word(new_image['name'])
|
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?<br/><br/>
|
||||||
|
|
||||||
|
Sua conta foi criada na EDUSEG pela empresa <b>{org_name}</b>.<br/><br/>
|
||||||
|
|
||||||
|
<a href="https://id.saladeaula.digital/register">
|
||||||
|
👉 Clique aqui para fazer seu primeiro acesso
|
||||||
|
</a>
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
subject = f'{first_name}, sua conta na EDUSEG® foi criada'
|
||||||
|
body = f"""
|
||||||
|
Oi {first_name}, tudo bem?<br/><br/>
|
||||||
|
|
||||||
|
Sua conta na EDUSEG® foi criada com sucesso.<br/><br/>
|
||||||
|
|
||||||
|
<a href="https://scorm.eduseg.workers.dev/settings/emails/{code}/verify">
|
||||||
|
👉 Clique aqui para verificar endereço de email
|
||||||
|
</a>
|
||||||
|
"""
|
||||||
|
|
||||||
emailmsg = Message(
|
emailmsg = Message(
|
||||||
from_=EMAIL_SENDER,
|
from_=EMAIL_SENDER,
|
||||||
to=(new_image['name'], new_image['email']),
|
to=(new_image['name'], new_image['email']),
|
||||||
subject=SUBJECT.format(first_name=first_name),
|
subject=subject,
|
||||||
)
|
|
||||||
emailmsg.add_alternative(
|
|
||||||
MESSAGE.format(
|
|
||||||
user_id=new_image['id'],
|
|
||||||
first_name=first_name,
|
|
||||||
org_name=new_image.get('org_name'),
|
|
||||||
code=hash,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
emailmsg.add_alternative(body)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sesv2_client.send_email(
|
sesv2_client.send_email(
|
||||||
|
|||||||
@@ -190,8 +190,6 @@ Resources:
|
|||||||
- prefix: EMAIL_VERIFICATION#
|
- prefix: EMAIL_VERIFICATION#
|
||||||
welcome:
|
welcome:
|
||||||
- exists: true
|
- exists: true
|
||||||
org_name:
|
|
||||||
- exists: true
|
|
||||||
|
|
||||||
EventSendVerificationEmailFunction:
|
EventSendVerificationEmailFunction:
|
||||||
Type: AWS::Serverless::Function
|
Type: AWS::Serverless::Function
|
||||||
|
|||||||
Reference in New Issue
Block a user