mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-12-01 06:55:45 +01:00
fixed auth handling for access control
This commit is contained in:
@@ -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...');
|
||||
|
||||
Reference in New Issue
Block a user