Skip to content

Commit

Permalink
Redirect to login page if an API call returns a 401 #551
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauleing committed Oct 30, 2024
1 parent c4fb586 commit fd296ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jqm-all/jqm-ws/src/main/react/src/utils/APIService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export default class APIService {
...init,
});


if (res.status === 401) { // Redirect to login user is not authenticated
window.location.href = "/auth/login.html";
}

if (res.ok) {
if (res.status === 200 || res.status === 201) {
return jsonResponse ? await res.json() : await res.text();
Expand Down

0 comments on commit fd296ee

Please sign in to comment.