diff --git a/console/console-src/modules/system/roles/components/RoleEditingModal.vue b/console/console-src/modules/system/roles/components/RoleEditingModal.vue index 00b1d1a56..c093e5754 100644 --- a/console/console-src/modules/system/roles/components/RoleEditingModal.vue +++ b/console/console-src/modules/system/roles/components/RoleEditingModal.vue @@ -154,6 +154,15 @@ const handleResetForm = () => { type="text" validation="required|length:0,50" > + diff --git a/console/console-src/router/guards/auth-check.ts b/console/console-src/router/guards/auth-check.ts index 6d2be5a5b..710d579ca 100644 --- a/console/console-src/router/guards/auth-check.ts +++ b/console/console-src/router/guards/auth-check.ts @@ -1,3 +1,4 @@ +import { rbacAnnotations } from "@/constants/annotations"; import { useUserStore } from "@/stores/user"; import type { Router } from "vue-router"; @@ -29,12 +30,26 @@ export function setupAuthCheckGuard(router: Router) { redirect_uri: to.query.redirect_uri, }, }); - } else { - next({ - name: "Dashboard", - }); return; } + + const roleHasRedirectOnLogin = userStore.currentRoles?.find( + (role) => + role.metadata.annotations?.[rbacAnnotations.REDIRECT_ON_LOGIN] + ); + + if (roleHasRedirectOnLogin) { + window.location.href = + roleHasRedirectOnLogin.metadata.annotations?.[ + rbacAnnotations.REDIRECT_ON_LOGIN + ] || "/"; + return; + } + + next({ + name: "Dashboard", + }); + return; } } diff --git a/console/src/constants/annotations.ts b/console/src/constants/annotations.ts index 76ae27bab..93ee694cf 100644 --- a/console/src/constants/annotations.ts +++ b/console/src/constants/annotations.ts @@ -11,6 +11,7 @@ export enum rbacAnnotations { DEPENDENCIES = "rbac.authorization.halo.run/dependencies", AVATAR_ATTACHMENT_NAME = "halo.run/avatar-attachment-name", LAST_AVATAR_ATTACHMENT_NAME = "halo.run/last-avatar-attachment-name", + REDIRECT_ON_LOGIN = "rbac.authorization.halo.run/redirect-on-login", } // content