diff --git a/src/app/apolloClient.js b/src/app/apolloClient.js index 9c3ebdd..8949327 100644 --- a/src/app/apolloClient.js +++ b/src/app/apolloClient.js @@ -3,10 +3,7 @@ import { setContext } from "@apollo/client/link/context"; import { createPersistedQueryLink } from "apollo-link-persisted-queries"; import cachedZones from "./cached-data/zones.json"; -import { - getAuthModeFeatureFlag, - readCypressLoginData, -} from "./components/useCurrentUser"; +import { getAuthModeFeatureFlag } from "./components/useCurrentUser"; // Teach Apollo to load certain fields from the cache, to avoid extra network // requests. This happens a lot - e.g. reusing data from item search on the @@ -192,13 +189,7 @@ const authModeLink = setContext((_, { headers = {} }) => { }); async function getAccessToken(getAuth0) { - // Our Cypress tests store login data separately. Use it if available! - const cypressToken = readCypressLoginData()?.encodedToken; - if (cypressToken) { - return cypressToken; - } - - // Otherwise, wait for auth0 to stop loading, so we can maybe get a token! + // Wait for auth0 to stop loading, so we can maybe get a token! // We'll do this hackily by checking every 100ms until it's true. await new Promise((resolve) => { function check() { diff --git a/src/app/components/useCurrentUser.js b/src/app/components/useCurrentUser.js index 9f4bee0..798a6c5 100644 --- a/src/app/components/useCurrentUser.js +++ b/src/app/components/useCurrentUser.js @@ -40,17 +40,6 @@ function useCurrentUser() { }; } - // Additionally, our Cypress tests do an actual end-to-end login as a test - // user. Use that token if present! - const cypressUser = readCypressLoginData()?.decodedUser; - if (cypressUser) { - return { - isLoading: false, - isLoggedIn: true, - ...getUserInfoFromAuth0Data(cypressUser), - }; - } - if (authMode === "auth0") { return currentUserViaAuth0; } else if (authMode === "db") { @@ -133,22 +122,6 @@ function useCurrentUserViaDb({ isEnabled }) { } } -export function readCypressLoginData() { - const cypressUserJsonString = window.localStorage.getItem("auth0Cypress"); - if (!cypressUserJsonString) { - return null; - } - - try { - return JSON.parse(cypressUserJsonString); - } catch (e) { - console.warn( - "Could not parse auth0Cypress token in localStorage; ignoring." - ); - return null; - } -} - function getUserInfoFromAuth0Data(user) { return { id: user.sub?.match(/^auth0\|impress-([0-9]+)$/)?.[1],