add flash message

This commit is contained in:
2025-11-30 20:11:26 -03:00
parent b5f3648f44
commit 9a0272af1d
8 changed files with 111 additions and 21 deletions

View File

@@ -52,8 +52,13 @@ def add(
)
with dyn.transact_writer() as transact:
transact.condition(
transact.update(
key=KeyPair(user_id, '0'),
# Makes the email searchable
update_expr='ADD emails :email',
expr_attr_values={
':email': {email},
},
cond_expr='attribute_exists(sk)',
exc_cls=UserNotFoundError,
)
@@ -75,6 +80,7 @@ def add(
'sk': email,
'created_at': now_,
},
# Prevent duplicate emails
cond_expr='attribute_not_exists(sk)',
exc_cls=EmailConflictError,
)
@@ -172,7 +178,7 @@ def verify(user_id: str, code: str):
exc_cls=UserNotFoundError,
)
return JSONResponse(status_code=HTTPStatus.NO_CONTENT)
return JSONResponse(status_code=HTTPStatus.OK, body={'email_verified': email})
@router.patch('/<user_id>/emails/primary')
@@ -213,13 +219,11 @@ def primary(
)
transact.update(
key=KeyPair(user_id, '0'),
update_expr='DELETE emails :email_set \
SET email = :email, \
update_expr='SET email = :email, \
email_verified = :email_verified, \
updated_at = :now',
expr_attr_values={
':email': new_email,
':email_set': {new_email},
':email_verified': email_verified,
':now': now_,
},