fix(auth): update cookie key to use 'shopit.front.auth.token' for consistency
This commit is contained in:
@@ -72,13 +72,13 @@ describe('AuthService', () => {
|
|||||||
expect(service.token()).toBe('plain-text-token');
|
expect(service.token()).toBe('plain-text-token');
|
||||||
expect(service.user()?.email).toBe('ada@example.com');
|
expect(service.user()?.email).toBe('ada@example.com');
|
||||||
expect(service.isAuthenticated()).toBe(true);
|
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();
|
httpController.verify();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hydrates token from cookies and loads the current user during bootstrap', async () => {
|
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({
|
TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
@@ -152,7 +152,7 @@ describe('AuthService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('clears an expired session when /me returns 401', async () => {
|
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({
|
TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
@@ -176,7 +176,7 @@ describe('AuthService', () => {
|
|||||||
expect(service.user()).toBeNull();
|
expect(service.user()).toBeNull();
|
||||||
expect(service.token()).toBeNull();
|
expect(service.token()).toBeNull();
|
||||||
expect(service.isAuthenticated()).toBe(false);
|
expect(service.isAuthenticated()).toBe(false);
|
||||||
expect(cookieStore['shopit.auth.token']).toBeUndefined();
|
expect(cookieStore['shopit.front.auth.token']).toBeUndefined();
|
||||||
|
|
||||||
httpController.verify();
|
httpController.verify();
|
||||||
});
|
});
|
||||||
@@ -384,7 +384,7 @@ describe('AuthService', () => {
|
|||||||
|
|
||||||
expect(service.token()).toBe('plain-text-token');
|
expect(service.token()).toBe('plain-text-token');
|
||||||
expect(service.user()?.email).toBe('ada@example.com');
|
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();
|
httpController.verify();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
import { CookieService } from '../cookie/cookie.service';
|
import { CookieService } from '../cookie/cookie.service';
|
||||||
import { TenantService } from '../tenant.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<AuthUser>('shopit.auth.user');
|
const AUTH_USER_SSR_STATE_KEY = makeStateKey<AuthUser>('shopit.auth.user');
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|||||||
Reference in New Issue
Block a user