Skip to content

Commit

Permalink
Merge pull request #89 from CybercentreCanada/hotfix/api_debug
Browse files Browse the repository at this point in the history
Hotfix/api debug
  • Loading branch information
cccs-sgaron authored Jul 13, 2021
2 parents c886905 + 37e2034 commit 42797e9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/components/hooks/useMyAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ export default function useMyAPI() {

// Fetch the URL
fetch(url, requestOptions)
.then(res => {
if (res.status === 401 && reloadOnUnauthorize) {
// Trigger a page reload, we're not logged in anymore
window.location.reload(false);
}
return res.json();
})
.then(res => res.json())
.catch(err => {
// eslint-disable-next-line no-console
console.error(err);
Expand All @@ -81,6 +75,7 @@ export default function useMyAPI() {
} else if (api_data.api_status_code === 401 && reloadOnUnauthorize) {
// Detect login request
// Do nothing... we are reloading the page
window.location.reload();
return;
} else if (api_data.api_status_code !== 200) {
// Handle errors
Expand Down
2 changes: 1 addition & 1 deletion src/components/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default function LoginScreen({ allowUserPass, allowSignup, allowPWReset,
}
},
onSuccess: () => {
window.location.reload(false);
window.location.reload();
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/routes/login/reset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ResetPasswordNow({ buttonLoading, setButtonLoading }: ResetPassw
onExit: () => setButtonLoading(false),
onSuccess: () => {
setDone(true);
setTimeout(() => window.location.reload(false), 7000);
setTimeout(() => window.location.reload(), 7000);
}
});
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion src/components/routes/submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function Submit() {
const data = JSON.parse(api_data);
if (Object.hasOwnProperty.call(data, 'api_status_code')) {
if (data.api_status_code === 401) {
window.location.reload(false);
window.location.reload();
}
}
} catch (ex) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/routes/tos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Tos() {
function acceptTOS() {
apiCall({
url: `/api/v4/user/tos/${currentUser.username}/`,
onSuccess: () => window.location.reload(false),
onSuccess: () => window.location.reload(),
onEnter: () => setButtonLoading(true),
onExit: () => setButtonLoading(false)
});
Expand All @@ -55,7 +55,7 @@ export default function Tos() {
function cancelTOS() {
apiCall({
url: '/api/v4/auth/logout/',
onSuccess: () => window.location.reload(false),
onSuccess: () => window.location.reload(),
onEnter: () => setButtonLoading(true),
onExit: () => setButtonLoading(false)
});
Expand Down

0 comments on commit 42797e9

Please sign in to comment.