diff --git a/app/components/Authenticated.tsx b/app/components/Authenticated.tsx
index 4573af668..924e5da8d 100644
--- a/app/components/Authenticated.tsx
+++ b/app/components/Authenticated.tsx
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
import { Redirect } from "react-router-dom";
import useStores from "~/hooks/useStores";
import { changeLanguage } from "~/utils/language";
+import LoadingIndicator from "./LoadingIndicator";
type Props = {
children: JSX.Element;
@@ -24,6 +25,10 @@ const Authenticated = ({ children }: Props) => {
return children;
}
+ if (auth.isFetching) {
+ return ;
+ }
+
void auth.logout(true);
return ;
};
diff --git a/app/stores/AuthStore.ts b/app/stores/AuthStore.ts
index 1ca3eaec4..51856ce4e 100644
--- a/app/stores/AuthStore.ts
+++ b/app/stores/AuthStore.ts
@@ -81,6 +81,9 @@ export default class AuthStore {
@observable
isSaving = false;
+ @observable
+ isFetching = true;
+
/* Whether the user is currently suspended. */
@observable
isSuspended = false;
@@ -178,6 +181,8 @@ export default class AuthStore {
@action
fetch = async () => {
+ this.isFetching = true;
+
try {
const res = await client.post("/auth.info", undefined, {
credentials: "same-origin",
@@ -234,6 +239,8 @@ export default class AuthStore {
this.isSuspended = true;
this.suspendedContactEmail = err.data.adminEmail;
}
+ } finally {
+ this.isFetching = false;
}
};