debug: Add admin guard logging
This commit is contained in:
@@ -122,6 +122,8 @@ export const adminGuard: CanActivateFn = (route, state) => {
|
||||
const storage = inject(StorageService);
|
||||
const storedUser = storage.getUser<{ type?: string }>();
|
||||
|
||||
console.log('[ADMIN GUARD DEBUG] isAdmin():', authService.isAdmin(), 'storedUser?.type:', storedUser?.type, 'storedUser:', storedUser);
|
||||
|
||||
// Verify both signal and stored data agree on admin status
|
||||
if (authService.isAdmin() && storedUser?.type === 'ADMIN') {
|
||||
return true;
|
||||
@@ -129,7 +131,7 @@ export const adminGuard: CanActivateFn = (route, state) => {
|
||||
|
||||
// Log potential privilege escalation attempt
|
||||
if (authService.isAdmin() !== (storedUser?.type === 'ADMIN')) {
|
||||
console.warn('Admin guard: User type mismatch detected');
|
||||
console.warn('Admin guard: User type mismatch detected - isAdmin():', authService.isAdmin(), 'storedType:', storedUser?.type);
|
||||
}
|
||||
|
||||
notification.error('This page is only accessible to administrators.');
|
||||
|
||||
Reference in New Issue
Block a user