Skip to content

Commit 608860c

Browse files
authored
fix: detect post-login redirect on login.bloomreach.com domain (#200)
After successful login, the browser stays on eu.login.bloomreach.com and redirects to /my-account instead of navigating to a .bloomreach.co or .exponea.com domain. The isAuthenticatedPage() function did not recognize this as authenticated, causing CLI login to always time out. Add login domain detection: if on login.bloomreach.com, treat any path that is not a known public path (/, /login, /forgotten-password, /register) as authenticated.
1 parent 346814d commit 608860c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/core/src/__tests__/bloomreachAuth.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,22 @@ describe('bloomreachAuth helpers', () => {
9393
});
9494

9595
it('isAuthenticatedPage returns expected values', () => {
96+
// Project pages on .bloomreach.co
9697
expect(isAuthenticatedPage('https://power.bloomreach.co/project/123')).toBe(true);
98+
// Project pages on .exponea.com
99+
expect(isAuthenticatedPage('https://app.exponea.com/project/456')).toBe(true);
100+
// Login domain public paths are NOT authenticated
97101
expect(isAuthenticatedPage('https://eu.login.bloomreach.com/')).toBe(false);
102+
expect(isAuthenticatedPage('https://eu.login.bloomreach.com/login')).toBe(false);
103+
expect(isAuthenticatedPage('https://eu.login.bloomreach.com/forgotten-password')).toBe(false);
104+
expect(isAuthenticatedPage('https://eu.login.bloomreach.com/register')).toBe(false);
105+
// Login domain authenticated paths (post-login redirects)
106+
expect(isAuthenticatedPage('https://eu.login.bloomreach.com/my-account')).toBe(true);
107+
expect(isAuthenticatedPage('https://eu.login.bloomreach.com/my-account/user-profile')).toBe(true);
108+
// Login paths on project domains are NOT authenticated
98109
expect(isAuthenticatedPage('https://power.bloomreach.co/login')).toBe(false);
110+
// Invalid URLs
111+
expect(isAuthenticatedPage('not-a-valid-url')).toBe(false);
99112
});
100113
});
101114

packages/core/src/bloomreachAuth.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ export function isLoginPage(url: string): boolean {
6363
}
6464
}
6565

66+
/** Non-authenticated paths on the login domain. */
67+
const LOGIN_DOMAIN_PUBLIC_PATHS = new Set(['/', '/login', '/forgotten-password', '/register']);
68+
6669
export function isAuthenticatedPage(url: string): boolean {
6770
try {
6871
const parsed = new URL(url);
72+
// After login, browser stays on login.bloomreach.com but moves to /my-account
73+
if (parsed.hostname.includes('login.bloomreach.com')) {
74+
return !LOGIN_DOMAIN_PUBLIC_PATHS.has(parsed.pathname);
75+
}
76+
// Or navigates to project pages on .bloomreach.co or .exponea.com
6977
return (parsed.hostname.endsWith('.bloomreach.co') || parsed.hostname.endsWith('.exponea.com')) && parsed.pathname !== '/login';
7078
} catch {
7179
return false;

0 commit comments

Comments
 (0)