fixed auth handling for access control

This commit is contained in:
2025-10-21 10:23:17 +02:00
parent 5254d3823a
commit 59b09b663e
3 changed files with 8 additions and 10 deletions

View File

@@ -135,10 +135,14 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
};
const hasRole = (roles: string[]): boolean => {
if (!user) return false;
return roles.length != 0;
if (!user || !user.roles || user.roles.length === 0) return false;
// Check if user has at least one of the required roles
return roles.some(requiredRole =>
user.roles!.includes(requiredRole)
);
};
useEffect(() => {
const initializeAuth = async () => {
console.log('🚀 Initializing authentication...');