New enterprise feature

This commit is contained in:
Urtzi Alfaro
2025-11-30 09:12:40 +01:00
parent f9d0eec6ec
commit 972db02f6d
176 changed files with 19741 additions and 1361 deletions

View File

@@ -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();