Skip to content

Commit 4b4bfc3

Browse files
committed
get detail from response in authenticate_user
1 parent ab52385 commit 4b4bfc3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cads_processing_api_service/auth.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,18 @@ def authenticate_user(
106106
SETTINGS.portal_header_name: portal_header,
107107
},
108108
)
109+
response_content: dict[str, Any] = response.json()
109110
if response.status_code in (
110111
fastapi.status.HTTP_401_UNAUTHORIZED,
111112
fastapi.status.HTTP_403_FORBIDDEN,
112113
):
113114
raise exceptions.PermissionDenied(
114115
status_code=response.status_code,
115-
title=response.json()["title"],
116-
detail="operation not allowed",
116+
title=response_content["title"],
117+
detail=response_content.get("detail", "operation not allowed"),
117118
)
118119
response.raise_for_status()
119-
user: dict[str, str] = response.json()
120+
user: dict[str, str] = response_content
120121
user_uid: str = user["sub"]
121122
user_role: str | None = user.get("role", None)
122123
email: str | None = user.get("email", None)

0 commit comments

Comments
 (0)