From 832fad19bc6922a540754b41643219a2bac0e96f Mon Sep 17 00:00:00 2001 From: ncoronel Date: Wed, 12 Aug 2026 09:19:16 -0300 Subject: [PATCH] fix(auth): update cookie key to use 'shopit.front.auth.token' for consistency --- src/app/core/services/auth/auth.service.spec.ts | 10 +++++----- src/app/core/services/auth/auth.service.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/core/services/auth/auth.service.spec.ts b/src/app/core/services/auth/auth.service.spec.ts index f9f6d3f..e46ec8f 100644 --- a/src/app/core/services/auth/auth.service.spec.ts +++ b/src/app/core/services/auth/auth.service.spec.ts @@ -72,13 +72,13 @@ describe('AuthService', () => { expect(service.token()).toBe('plain-text-token'); expect(service.user()?.email).toBe('ada@example.com'); expect(service.isAuthenticated()).toBe(true); - expect(cookieStore['shopit.auth.token']).toBe('plain-text-token'); + expect(cookieStore['shopit.front.auth.token']).toBe('plain-text-token'); httpController.verify(); }); it('hydrates token from cookies and loads the current user during bootstrap', async () => { - cookieStore['shopit.auth.token'] = 'persisted-token'; + cookieStore['shopit.front.auth.token'] = 'persisted-token'; TestBed.configureTestingModule({ providers: [ @@ -152,7 +152,7 @@ describe('AuthService', () => { }); it('clears an expired session when /me returns 401', async () => { - cookieStore['shopit.auth.token'] = 'expired-token'; + cookieStore['shopit.front.auth.token'] = 'expired-token'; TestBed.configureTestingModule({ providers: [ @@ -176,7 +176,7 @@ describe('AuthService', () => { expect(service.user()).toBeNull(); expect(service.token()).toBeNull(); expect(service.isAuthenticated()).toBe(false); - expect(cookieStore['shopit.auth.token']).toBeUndefined(); + expect(cookieStore['shopit.front.auth.token']).toBeUndefined(); httpController.verify(); }); @@ -384,7 +384,7 @@ describe('AuthService', () => { expect(service.token()).toBe('plain-text-token'); expect(service.user()?.email).toBe('ada@example.com'); - expect(cookieStore['shopit.auth.token']).toBe('plain-text-token'); + expect(cookieStore['shopit.front.auth.token']).toBe('plain-text-token'); httpController.verify(); }); diff --git a/src/app/core/services/auth/auth.service.ts b/src/app/core/services/auth/auth.service.ts index a2d45f3..98f36b2 100644 --- a/src/app/core/services/auth/auth.service.ts +++ b/src/app/core/services/auth/auth.service.ts @@ -21,7 +21,7 @@ import { import { CookieService } from '../cookie/cookie.service'; import { TenantService } from '../tenant.service'; -const AUTH_TOKEN_COOKIE_KEY = 'shopit.auth.token'; +const AUTH_TOKEN_COOKIE_KEY = 'shopit.front.auth.token'; const AUTH_USER_SSR_STATE_KEY = makeStateKey('shopit.auth.user'); @Injectable({