feat: Improve role verification logic in InterestDuplicateNotificationBanner for duplicate checks

This commit is contained in:
Matt 2025-07-09 22:08:08 -04:00
parent 3f90db0392
commit b6d71faf5f
1 changed files with 4 additions and 3 deletions

View File

@ -50,15 +50,16 @@ const checkForDuplicates = async () => {
try {
loading.value = true;
// Check roles with better error handling
// Check roles with better error handling - use hasAnyRole for multiple roles
const { hasAnyRole, isAdmin, isSalesOrAdmin } = useAuthorization();
let canViewDuplicates = false;
try {
canViewDuplicates = await hasRole(['sales', 'admin']);
canViewDuplicates = isSalesOrAdmin(); // Use the convenience method
console.log('[InterestDuplicateNotification] Role check result:', canViewDuplicates);
} catch (roleError) {
console.error('[InterestDuplicateNotification] Role check failed:', roleError);
// Try to get user info directly as fallback
const { isAdmin } = useAuthorization();
canViewDuplicates = isAdmin();
console.log('[InterestDuplicateNotification] Fallback admin check:', canViewDuplicates);
}