[web][photos] Fix infinite loop on half-logins

Fix an infinite loop of navigation under the following conditions: key is valid
but token is not present.

Fix is to match the condition used in both gallery

    if (!key || !token) {

and the root page.

They seemed to have diverged in commit c3304571a9.

Was able to reproduce this when launching the desktop app such that the key was
picked up (possibly from a prior installation) from the secure keychain, but the
token was not found. I feel this is also a fix for a similar navigation loop
recently reported by QA but unreproducible so far.
This commit is contained in:
Manav Rathi
2024-03-25 16:39:54 +05:30
parent 37dce2bdb5
commit eecb8b70f4

View File

@@ -17,6 +17,7 @@ import ElectronAPIs from "@ente/shared/electron";
import { getAlbumsURL } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { getKey, SESSION_KEYS } from "@ente/shared/storage/sessionStorage";
import isElectron from "is-electron";
import { Trans } from "react-i18next";
@@ -145,18 +146,11 @@ export default function LandingPage() {
);
}
}
if (key) {
// if (appName === APPS.AUTH) {
// await router.push(PAGES.AUTH);
// } else {
const token = getToken();
if (key && token) {
await router.push(PAGES.GALLERY);
// }
} else if (user?.email) {
await router.push(PAGES.VERIFY);
} else {
// if (appName === APPS.AUTH) {
// await router.push(PAGES.LOGIN);
// }
}
await initLocalForage();
setLoading(false);