feat: Improve role verification logic in InterestDuplicateNotificationBanner for duplicate checks
This commit is contained in:
parent
3f90db0392
commit
b6d71faf5f
|
|
@ -50,15 +50,16 @@ const checkForDuplicates = async () => {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
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;
|
let canViewDuplicates = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
canViewDuplicates = await hasRole(['sales', 'admin']);
|
canViewDuplicates = isSalesOrAdmin(); // Use the convenience method
|
||||||
console.log('[InterestDuplicateNotification] Role check result:', canViewDuplicates);
|
console.log('[InterestDuplicateNotification] Role check result:', canViewDuplicates);
|
||||||
} catch (roleError) {
|
} catch (roleError) {
|
||||||
console.error('[InterestDuplicateNotification] Role check failed:', roleError);
|
console.error('[InterestDuplicateNotification] Role check failed:', roleError);
|
||||||
// Try to get user info directly as fallback
|
// Try to get user info directly as fallback
|
||||||
const { isAdmin } = useAuthorization();
|
|
||||||
canViewDuplicates = isAdmin();
|
canViewDuplicates = isAdmin();
|
||||||
console.log('[InterestDuplicateNotification] Fallback admin check:', canViewDuplicates);
|
console.log('[InterestDuplicateNotification] Fallback admin check:', canViewDuplicates);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue