add fallback to id
This commit is contained in:
@@ -121,6 +121,8 @@ def _create_user(user: User, org: Org) -> bool:
|
||||
# 'org_id': {org.id},
|
||||
# 'created_at': now_,
|
||||
'createDate': now_,
|
||||
# Makes the email searchable
|
||||
'emails': {user.email},
|
||||
},
|
||||
)
|
||||
transact.put(
|
||||
@@ -137,8 +139,8 @@ def _create_user(user: User, org: Org) -> bool:
|
||||
'sk': f'emails#{user.email}',
|
||||
'email_verified': email_verified,
|
||||
'email_primary': True,
|
||||
'mx_record_exists': email_verified,
|
||||
'created_at': now_,
|
||||
**({'mx_record_exists': True} if email_verified else {}),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -20,13 +20,9 @@ router = Router()
|
||||
dyn = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
|
||||
|
||||
@router.get('/<user_id>/emails')
|
||||
def get_emails(user_id: str, start_key: Annotated[str | None, Query] = None):
|
||||
return dyn.collection.query(
|
||||
# Post-migration (users): rename `emails` to `EMAIL`
|
||||
key=KeyPair(user_id, 'emails'),
|
||||
start_key=start_key,
|
||||
)
|
||||
class ConflictError(ServiceError):
|
||||
def __init__(self, msg: str | dict):
|
||||
super().__init__(HTTPStatus.CONFLICT, msg)
|
||||
|
||||
|
||||
class UserNotFoundError(NotFoundError): ...
|
||||
@@ -35,9 +31,19 @@ class UserNotFoundError(NotFoundError): ...
|
||||
class EmailNotFoundError(NotFoundError): ...
|
||||
|
||||
|
||||
class EmailConflictError(ServiceError):
|
||||
def __init__(self, msg: str | dict):
|
||||
super().__init__(HTTPStatus.CONFLICT, msg)
|
||||
class EmailVerificationNotFoundError(NotFoundError): ...
|
||||
|
||||
|
||||
class EmailConflictError(ConflictError): ...
|
||||
|
||||
|
||||
@router.get('/<user_id>/emails')
|
||||
def get_emails(user_id: str, start_key: Annotated[str | None, Query] = None):
|
||||
return dyn.collection.query(
|
||||
# Post-migration (users): rename `emails` to `EMAIL`
|
||||
key=KeyPair(user_id, 'emails'),
|
||||
start_key=start_key,
|
||||
)
|
||||
|
||||
|
||||
@router.post('/<user_id>/emails')
|
||||
@@ -68,7 +74,6 @@ def add(
|
||||
# Post-migration (users): rename `emails` to `EMAIL`
|
||||
'sk': f'emails#{email}',
|
||||
'email_verified': False,
|
||||
'mx_record_exists': False,
|
||||
'email_primary': False,
|
||||
'created_at': now_,
|
||||
}
|
||||
@@ -124,9 +129,6 @@ def request_verification(
|
||||
return JSONResponse(status_code=HTTPStatus.NO_CONTENT)
|
||||
|
||||
|
||||
class EmailVerificationNotFoundError(NotFoundError): ...
|
||||
|
||||
|
||||
@router.post('/<user_id>/emails/<code>/verify')
|
||||
def verify(user_id: str, code: str):
|
||||
r = dyn.collection.get_items(
|
||||
|
||||
Reference in New Issue
Block a user