Enhance authorization handling by syncing auth state from Nuxt payload and loading from API if necessary; improve dashboard logging for user roles and groups
This commit is contained in:
@@ -72,12 +72,26 @@ definePageMeta({
|
||||
|
||||
const { mdAndDown } = useDisplay();
|
||||
const { user, logout, authSource } = useUnifiedAuth();
|
||||
const { isAdmin } = useAuthorization();
|
||||
const { isAdmin, getUserGroups, getCurrentUser } = useAuthorization();
|
||||
const tags = usePortalTags();
|
||||
|
||||
const drawer = ref(false);
|
||||
|
||||
// Debug auth state
|
||||
onMounted(() => {
|
||||
console.log('[Dashboard] Auth state on mount:', {
|
||||
isAdmin: isAdmin(),
|
||||
userGroups: getUserGroups(),
|
||||
currentUser: getCurrentUser()
|
||||
});
|
||||
});
|
||||
|
||||
const interestMenu = computed(() => {
|
||||
const userIsAdmin = isAdmin();
|
||||
const userGroups = getUserGroups();
|
||||
|
||||
console.log('[Dashboard] Computing interest menu - isAdmin:', userIsAdmin, 'groups:', userGroups);
|
||||
|
||||
const baseMenu = [
|
||||
//{
|
||||
// to: "/dashboard/interest-eoi-queue",
|
||||
@@ -122,7 +136,8 @@ const interestMenu = computed(() => {
|
||||
];
|
||||
|
||||
// Add admin menu items if user is admin
|
||||
if (isAdmin()) {
|
||||
if (userIsAdmin) {
|
||||
console.log('[Dashboard] Adding admin console to interest menu');
|
||||
baseMenu.push({
|
||||
to: "/dashboard/admin",
|
||||
icon: "mdi-shield-crown",
|
||||
@@ -134,6 +149,11 @@ const interestMenu = computed(() => {
|
||||
});
|
||||
|
||||
const defaultMenu = computed(() => {
|
||||
const userIsAdmin = isAdmin();
|
||||
const userGroups = getUserGroups();
|
||||
|
||||
console.log('[Dashboard] Computing default menu - isAdmin:', userIsAdmin, 'groups:', userGroups);
|
||||
|
||||
const baseMenu = [
|
||||
{
|
||||
to: "/dashboard/site",
|
||||
@@ -153,7 +173,8 @@ const defaultMenu = computed(() => {
|
||||
];
|
||||
|
||||
// Add admin menu items if user is admin
|
||||
if (isAdmin()) {
|
||||
if (userIsAdmin) {
|
||||
console.log('[Dashboard] Adding admin console to default menu');
|
||||
baseMenu.push({
|
||||
to: "/dashboard/admin",
|
||||
icon: "mdi-shield-crown",
|
||||
|
||||
Reference in New Issue
Block a user