summaryrefslogtreecommitdiff
path: root/web/source/settings
diff options
context:
space:
mode:
Diffstat (limited to 'web/source/settings')
-rw-r--r--web/source/settings/components/authorization/index.tsx11
-rw-r--r--web/source/settings/lib/query/login/index.ts2
2 files changed, 10 insertions, 3 deletions
diff --git a/web/source/settings/components/authorization/index.tsx b/web/source/settings/components/authorization/index.tsx
index 3eeeb393a..6b64e43e8 100644
--- a/web/source/settings/components/authorization/index.tsx
+++ b/web/source/settings/components/authorization/index.tsx
@@ -27,7 +27,7 @@ import { Error } from "../error";
import { NoArg } from "../../lib/types/query";
export function Authorization({ App }) {
- const { current: loginState, expectingRedirect } = store.getState().login;
+ const { current: loginState, token: token, expectingRedirect } = store.getState().login;
const skip = (loginState == "none" || loginState == "loggedout" || expectingRedirect);
const [ logoutQuery ] = useLogoutMutation();
@@ -60,7 +60,14 @@ export function Authorization({ App }) {
} else if (error !== undefined) {
// Something went wrong,
// log the user out.
- logoutQuery(NoArg);
+
+ // token can be undefined in some cases
+ // (ex: user going back to /settings after abandoning login)
+ // logoutQuery should only be called when token is defined,
+ // since that function revokes the token
+ if (token !== undefined) {
+ logoutQuery(NoArg);
+ }
content = (
<div>
diff --git a/web/source/settings/lib/query/login/index.ts b/web/source/settings/lib/query/login/index.ts
index 1f56a51c5..e35227aba 100644
--- a/web/source/settings/lib/query/login/index.ts
+++ b/web/source/settings/lib/query/login/index.ts
@@ -141,7 +141,7 @@ const extended = gtsApi.injectEndpoints({
}
instanceUrl = new URL(formData.instance).origin;
- if (loginState?.instanceUrl == instanceUrl && loginState.app) {
+ if (loginState?.instanceUrl == instanceUrl && loginState.app && loginState.token !== undefined) {
return { data: loginState.app };
}