-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Conversation
|
WalkthroughThe changes enhance the access control logic in the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- apps/web-antd/src/router/guard.ts (1 hunks)
- apps/web-ele/src/router/guard.ts (1 hunks)
- apps/web-naive/src/router/guard.ts (1 hunks)
Additional comments not posted (6)
apps/web-antd/src/router/guard.ts (2)
65-71
: Improve readability and maintainability.The added logic for handling core routes that do not require permission checks is clear and improves the readability of the code. Separating the core route check into its own conditional block makes the control flow more organized.
67-68
: Ensure correct redirection for login path.The added logic correctly handles the case where the route is the login path and an access token is present, redirecting the user to the specified path or the homepage. This ensures that users are not redirected back to the login page after logging in.
apps/web-ele/src/router/guard.ts (2)
65-71
: Improve readability and maintainability.The added logic for handling core routes that do not require permission checks is clear and improves the readability of the code. Separating the core route check into its own conditional block makes the control flow more organized.
67-68
: Ensure correct redirection for login path.The added logic correctly handles the case where the route is the login path and an access token is present, redirecting the user to the specified path or the homepage. This ensures that users are not redirected back to the login page after logging in.
apps/web-naive/src/router/guard.ts (2)
65-71
: Improve readability and maintainability.The added logic for handling core routes that do not require permission checks is clear and improves the readability of the code. Separating the core route check into its own conditional block makes the control flow more organized.
67-68
: Ensure correct redirection for login path.The added logic correctly handles the case where the route is the login path and an access token is present, redirecting the user to the specified path or the homepage. This ensures that users are not redirected back to the login page after logging in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (3)
apps/web-antd/src/router/guard.ts (1)
3-3
: Reorder import statements for better readability.The import statement
DEFAULT_HOME_PATH
should come beforeLOGIN_PATH
to follow the alphabetical order.-import { LOGIN_PATH, DEFAULT_HOME_PATH } from '@vben/constants'; +import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';Tools
GitHub Check: Lint (20, macos-latest)
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"GitHub Check: Lint (20, ubuntu-latest)
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"apps/web-ele/src/router/guard.ts (1)
3-3
: Reorder import statements for better readability.The import statement
DEFAULT_HOME_PATH
should come beforeLOGIN_PATH
to follow the alphabetical order.-import { LOGIN_PATH, DEFAULT_HOME_PATH } from '@vben/constants'; +import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';Tools
GitHub Check: Lint (20, macos-latest)
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"GitHub Check: Lint (20, ubuntu-latest)
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"apps/web-naive/src/router/guard.ts (1)
3-3
: Reorder import statements for better readability.The import statement
DEFAULT_HOME_PATH
should come beforeLOGIN_PATH
to follow the alphabetical order.-import { LOGIN_PATH, DEFAULT_HOME_PATH } from '@vben/constants'; +import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';Tools
GitHub Check: Lint (20, macos-latest)
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"GitHub Check: Lint (20, ubuntu-latest)
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- apps/web-antd/src/router/guard.ts (2 hunks)
- apps/web-ele/src/router/guard.ts (2 hunks)
- apps/web-naive/src/router/guard.ts (2 hunks)
Additional context used
GitHub Check: Lint (20, macos-latest)
apps/web-antd/src/router/guard.ts
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"apps/web-ele/src/router/guard.ts
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"apps/web-naive/src/router/guard.ts
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"
GitHub Check: Lint (20, ubuntu-latest)
apps/web-antd/src/router/guard.ts
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"apps/web-ele/src/router/guard.ts
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"apps/web-naive/src/router/guard.ts
[failure] 3-3:
Expected "DEFAULT_HOME_PATH" to come before "LOGIN_PATH"
Additional comments not posted (3)
apps/web-antd/src/router/guard.ts (1)
65-73
: LGTM! But verify the function usage in the codebase.The code changes improve the clarity and efficiency of the access guard logic.
However, ensure that all function calls to
setupAccessGuard
match the new logic.Verification successful
LGTM! The
setupAccessGuard
function implementation is consistent across all relevant files.The code changes improve the clarity and efficiency of the access guard logic.
apps/web-naive/src/router/guard.ts
apps/web-antd/src/router/guard.ts
apps/web-ele/src/router/guard.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `setupAccessGuard` match the new logic. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg --type javascript -A 5 $'setupAccessGuard'Length of output: 79
Script:
#!/bin/bash # Description: Verify all function calls to `setupAccessGuard` match the new logic. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg --type js -A 5 $'setupAccessGuard'Length of output: 36
Script:
#!/bin/bash # Description: Verify the existence and usage of the `setupAccessGuard` function across all file types. # Search for the definition of `setupAccessGuard` function rg 'function setupAccessGuard' # Search for any potential usage of `setupAccessGuard` across all file types rg 'setupAccessGuard'Length of output: 708
Script:
#!/bin/bash # Description: Compare the `setupAccessGuard` function implementation across three files to ensure consistency. # Extract the `setupAccessGuard` function implementation from each file rg --type ts -A 20 'function setupAccessGuard' apps/web-naive/src/router/guard.ts rg --type ts -A 20 'function setupAccessGuard' apps/web-antd/src/router/guard.ts rg --type ts -A 20 'function setupAccessGuard' apps/web-ele/src/router/guard.tsLength of output: 2144
apps/web-ele/src/router/guard.ts (1)
65-73
: LGTM! But verify the function usage in the codebase.The code changes improve the clarity and efficiency of the access guard logic.
However, ensure that all function calls to
setupAccessGuard
match the new logic.apps/web-naive/src/router/guard.ts (1)
65-73
: LGTM! But verify the function usage in the codebase.The code changes improve the clarity and efficiency of the access guard logic.
However, ensure that all function calls to
setupAccessGuard
match the new logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
The ci didn't pass. You can check it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- apps/web-antd/src/router/guard.ts (2 hunks)
- apps/web-ele/src/router/guard.ts (2 hunks)
- apps/web-naive/src/router/guard.ts (2 hunks)
Additional comments not posted (6)
apps/web-antd/src/router/guard.ts (2)
3-3
: ImportDEFAULT_HOME_PATH
is a good addition.The addition of
DEFAULT_HOME_PATH
helps in providing a default redirect path for authenticated users.
65-73
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
setupAccessGuard
and its logic are correctly implemented throughout the codebase.Verification successful
The
setupAccessGuard
function is defined and used in three different files:apps/web-ele/src/router/guard.ts
,apps/web-naive/src/router/guard.ts
, andapps/web-antd/src/router/guard.ts
. The logic within these functions appears to be consistent across the files. Each instance sets up a router guard that checks for basic routes and handles redirection if the user is already authenticated.LGTM! The function
setupAccessGuard
and its logic are correctly implemented throughout the codebase.
apps/web-ele/src/router/guard.ts
apps/web-naive/src/router/guard.ts
apps/web-antd/src/router/guard.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `setupAccessGuard` and its logic. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg --type ts -A 10 $'setupAccessGuard'Length of output: 3103
apps/web-ele/src/router/guard.ts (2)
3-3
: ImportDEFAULT_HOME_PATH
is a good addition.The addition of
DEFAULT_HOME_PATH
helps in providing a default redirect path for authenticated users.
65-73
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
setupAccessGuard
and its logic are correctly implemented throughout the codebase.Verification successful
Function usage of
setupAccessGuard
verifiedThe
setupAccessGuard
function is correctly defined and called within the filesapps/web-ele/src/router/guard.ts
,apps/web-antd/src/router/guard.ts
, andapps/web-naive/src/router/guard.ts
. The logic within the function is consistent across these instances.
apps/web-ele/src/router/guard.ts
apps/web-antd/src/router/guard.ts
apps/web-naive/src/router/guard.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `setupAccessGuard` and its logic. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg --type ts -A 10 $'setupAccessGuard'Length of output: 3103
apps/web-naive/src/router/guard.ts (2)
3-3
: ImportDEFAULT_HOME_PATH
is a good addition.The addition of
DEFAULT_HOME_PATH
helps in providing a default redirect path for authenticated users.
65-73
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
setupAccessGuard
and its logic are correctly implemented throughout the codebase.Verification successful
Function usage verified
The function
setupAccessGuard
and its logic are correctly implemented and consistently used throughout the codebase in the following files:
apps/web-ele/src/router/guard.ts
apps/web-antd/src/router/guard.ts
apps/web-naive/src/router/guard.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `setupAccessGuard` and its logic. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg --type ts -A 10 $'setupAccessGuard'Length of output: 3103
It has been fixed. |
Description
After logging in, using the address bar
/auth/login
will not jump to the login page.close: #4051
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit
package.json
by removing unnecessary spaces in the scripts section for improved code cleanliness.