Shared status_code for all auth exceptions
| 3 | |
| 4 | |
| 5 | class AuthException(HTTPException): |
| 6 | """Shared status_code for all auth exceptions""" |
| 7 | |
| 8 | # TODO don't return detailed messages to the client in production |
| 9 | def __init__(self, detail: str = "Failed to authenticate user."): |
| 10 | super().__init__(status_code=401, detail=detail) |
| 11 | |
| 12 | @classmethod |
| 13 | def from_gotrue_autherror(cls, exc: gotrue.errors.AuthApiError): |
| 14 | """ |
| 15 | Create an AuthException from a GoTrue exception. |
| 16 | |
| 17 | This let's us handle explicit messaging to the user and prevents printing |
| 18 | all exception messages to the user. |
| 19 | """ |
| 20 | if exc.message == "Email not confirmed": |
| 21 | return AuthUnconfirmedEmailException() |
| 22 | return cls() # don't bubble messages we don't explicitly approve |
| 23 | |
| 24 | |
| 25 | class AuthUnconfirmedEmailException(AuthException): |
no outgoing calls
no test coverage detected
searching dependent graphs…