New enterprise feature
This commit is contained in:
@@ -43,7 +43,8 @@ export interface AuthState {
|
||||
updateUser: (updates: Partial<User>) => void;
|
||||
clearError: () => void;
|
||||
setLoading: (loading: boolean) => void;
|
||||
|
||||
setDemoAuth: (token: string, demoUser: Partial<User>) => void;
|
||||
|
||||
// Permission helpers
|
||||
hasPermission: (permission: string) => boolean;
|
||||
hasRole: (role: string) => boolean;
|
||||
@@ -234,6 +235,24 @@ export const useAuthStore = create<AuthState>()(
|
||||
set({ isLoading: loading });
|
||||
},
|
||||
|
||||
setDemoAuth: (token: string, demoUser: Partial<User>) => {
|
||||
console.log('🔧 [Auth Store] setDemoAuth called - demo sessions use X-Demo-Session-Id header, not JWT');
|
||||
// DO NOT set API client token for demo sessions!
|
||||
// Demo authentication works via X-Demo-Session-Id header, not JWT
|
||||
// The demo middleware handles authentication server-side
|
||||
|
||||
// Update store state so user is marked as authenticated
|
||||
set({
|
||||
token: null, // No JWT token for demo sessions
|
||||
refreshToken: null,
|
||||
user: demoUser as User,
|
||||
isAuthenticated: true, // User is authenticated via demo session
|
||||
isLoading: false,
|
||||
error: null,
|
||||
});
|
||||
console.log('✅ [Auth Store] Demo auth state updated (no JWT token)');
|
||||
},
|
||||
|
||||
// Permission helpers - Global user permissions only
|
||||
hasPermission: (_permission: string): boolean => {
|
||||
const { user } = get();
|
||||
|
||||
Reference in New Issue
Block a user