Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiog1901 committed Feb 14, 2024
1 parent a3f6cac commit 97aff84
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
6 changes: 3 additions & 3 deletions apiserver/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ async def get_current_user(
authenticate_value = "Bearer"

credentials_exception = HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
status_code=status.HTTP_403_FORBIDDEN,
detail="Could not validate authentication credentials",
headers={"WWW-Authenticate": authenticate_value},
)

Expand All @@ -200,7 +200,7 @@ async def get_current_user(
if scope not in token_scopes:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=f"Not enough permissions. Missing scopes: {security_scopes.scopes}",
detail=f"AuthZ exception. Missing scopes: {security_scopes.scopes}",
headers={"WWW-Authenticate": authenticate_value},
)

Expand Down
6 changes: 0 additions & 6 deletions webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap"
rel="stylesheet"
/>
<title>Worst</title>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/FabToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
<div
id="delete-button"
class="mx-2 flex cursor-pointer items-center justify-between rounded-xl hover:bg-green-400 bg-red-600 p-2 text-white"
class="mx-2 flex cursor-pointer items-center justify-between rounded-xl hover:bg-red-400 bg-red-600 p-2 text-white"
v-on:click="$emit('delete-clicked')"
>
<span class="mx-1">Delete</span>
Expand Down
26 changes: 19 additions & 7 deletions webapp/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,25 @@ function request(method: string) {
return r.data;
})
.catch((error) => {
if (error.response.status === 401) {
console.error("not authorized");
authStore.logout();
} else {
// TODO handle 422 gracefully
//return error.response;
authStore.logout();
switch (error.response.status) {
case 403: {
console.error("User is not authenticated");
authStore.logout();
break;
}
case 401: {
alert(error.response.data.detail);
break;
}
case 422: {
console.warn(JSON.stringify(error.response.data, undefined, 4));
alert(
`JSON object sent to apiserver does not comform to expectation.
Check error message in console log for details.
`,
);
break;
}
}
});
};
Expand Down

0 comments on commit 97aff84

Please sign in to comment.