forked from sr2/cloud-api
feat: more accurate status codes
403 Forbidden replacing many 401 Unauthorized usages.
This commit is contained in:
parent
b3ae655009
commit
c2e035dede
11 changed files with 81 additions and 74 deletions
|
|
@ -36,3 +36,12 @@ class ForbiddenException(HTTPException):
|
|||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=detail,
|
||||
)
|
||||
|
||||
|
||||
class UnauthorizedException(HTTPException):
|
||||
def __init__(self, message: Optional[str] = None) -> None:
|
||||
detail = "Not authorized" if not message else message
|
||||
super().__init__(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail=detail,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue