Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: successful login should not take you to the login page #4056

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions apps/web-antd/src/router/guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ function setupAccessGuard(router: Router) {
const userStore = useUserStore();
const authStore = useAuthStore();

// 基本路由,这些路由不需要进入权限拦截
if (coreRouteNames.includes(to.name as string)) {
if (to.path === LOGIN_PATH && accessStore.accessToken) {
return decodeURIComponent((to.query?.redirect as string) || '/');
}
return true;
}

// accessToken 检查
if (!accessStore.accessToken) {
if (
// 基本路由,这些路由不需要进入权限拦截
coreRouteNames.includes(to.name as string) ||
// 明确声明忽略权限访问权限,则可以访问
to.meta.ignoreAccess
) {
// 明确声明忽略权限访问权限,则可以访问
if (to.meta.ignoreAccess) {
return true;
}

Expand Down
16 changes: 10 additions & 6 deletions apps/web-ele/src/router/guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ function setupAccessGuard(router: Router) {
const userStore = useUserStore();
const authStore = useAuthStore();

// 基本路由,这些路由不需要进入权限拦截
if (coreRouteNames.includes(to.name as string)) {
if (to.path === LOGIN_PATH && accessStore.accessToken) {
return decodeURIComponent((to.query?.redirect as string) || '/');
}
return true;
}

// accessToken 检查
if (!accessStore.accessToken) {
if (
// 基本路由,这些路由不需要进入权限拦截
coreRouteNames.includes(to.name as string) ||
// 明确声明忽略权限访问权限,则可以访问
to.meta.ignoreAccess
) {
// 明确声明忽略权限访问权限,则可以访问
if (to.meta.ignoreAccess) {
return true;
}

Expand Down
16 changes: 10 additions & 6 deletions apps/web-naive/src/router/guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ function setupAccessGuard(router: Router) {
const userStore = useUserStore();
const authStore = useAuthStore();

// 基本路由,这些路由不需要进入权限拦截
if (coreRouteNames.includes(to.name as string)) {
if (to.path === LOGIN_PATH && accessStore.accessToken) {
return decodeURIComponent((to.query?.redirect as string) || '/');
}
return true;
}

// accessToken 检查
if (!accessStore.accessToken) {
if (
// 基本路由,这些路由不需要进入权限拦截
coreRouteNames.includes(to.name as string) ||
// 明确声明忽略权限访问权限,则可以访问
to.meta.ignoreAccess
) {
// 明确声明忽略权限访问权限,则可以访问
if (to.meta.ignoreAccess) {
return true;
}

Expand Down
Loading