@@ -15,7 +15,7 @@ def __init__(self, logic: "Logic"):
1515
1616 async def create (self , email : str , password : str ) -> User | None :
1717 if await self .logic .db .user .retrieve_by_email (email ):
18- raise exps .USER_EXISTS
18+ raise exps .UserExistsException ()
1919
2020 password_hash = self .logic .security .pwd .hashpwd (password )
2121 model = User (email = email , password = password_hash )
@@ -25,17 +25,16 @@ async def create(self, email: str, password: str) -> User | None:
2525 async def generate_token (self , email : str , password : str ) -> AccessToken | None :
2626 if user := await self .logic .db .user .retrieve_by_email (email ):
2727 if not self .logic .security .pwd .checkpwd (password , user .password ):
28- raise exps .USER_IS_CORRECT
29- access_token = self .logic .security .jwt .encode_token (
30- {"id" : user .id }, 1440 )
28+ raise exps .UserIsCorrectException ()
29+ access_token = self .logic .security .jwt .encode_token ({"id" : user .id }, 1440 )
3130 return AccessToken (token = access_token )
32- raise exps .USER_NOT_FOUND
31+ raise exps .UserNotFoundException ()
3332
3433 async def retrieve_by_token (self , token : str ) -> User | None :
3534 if payload := self .logic .security .jwt .decode_token (token ):
3635 if not (
3736 user := await self .logic .db .user .retrieve_one (ident = payload .get ("id" ))
3837 ):
39- raise exps .USER_NOT_FOUND
38+ raise exps .UserNotFoundException ()
4039 else :
4140 return user
0 commit comments