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
|
|
@ -4,16 +4,3 @@ Module specific exceptions for the auth module
|
|||
Exceptions:
|
||||
- UnauthorizedException: Takes an optional message string
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
|
||||
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