diff --git a/__tests__/Auth0Client/helpers.ts b/__tests__/Auth0Client/helpers.ts index 8ea77e291..f85ac772c 100644 --- a/__tests__/Auth0Client/helpers.ts +++ b/__tests__/Auth0Client/helpers.ts @@ -150,7 +150,9 @@ export const loginWithRedirectFn = (mockWindow, mockFetch) => { customCallbackUrl } = processDefaultLoginWithRedirectOptions(testConfig); await auth0.loginWithRedirect(options); + const redirectMethod = options?.redirectMethod || 'assign'; + expect(mockWindow.location[redirectMethod]).toHaveBeenCalled(); if (error && errorDescription) { diff --git a/__tests__/Auth0Client/loginWithPopup.test.ts b/__tests__/Auth0Client/loginWithPopup.test.ts index c685693b2..2242097bf 100644 --- a/__tests__/Auth0Client/loginWithPopup.test.ts +++ b/__tests__/Auth0Client/loginWithPopup.test.ts @@ -614,6 +614,20 @@ describe('Auth0Client', () => { ); }); + it('removes the organization hint cookie if no org_id claim was returned in the ID token', async () => { + const auth0 = setup(); + + await loginWithPopup(auth0); + + expect(esCookie.remove).toHaveBeenCalledWith( + `_legacy_auth0.${TEST_CLIENT_ID}.organization_hint` + ); + + expect(esCookie.remove).toHaveBeenCalledWith( + `auth0.${TEST_CLIENT_ID}.organization_hint` + ); + }); + it('saves `auth0.is.authenticated` key in storage for an extended period', async () => { const auth0 = setup({ sessionCheckExpiryDays: 2 diff --git a/src/Auth0Client.ts b/src/Auth0Client.ts index 99ad220ef..beb4bdb30 100644 --- a/src/Auth0Client.ts +++ b/src/Auth0Client.ts @@ -478,6 +478,8 @@ export default class Auth0Client { this.orgHintCookieName, decodedToken.claims.org_id ); + } else { + this.cookieStorage.remove(this.orgHintCookieName); } }