fix(console): redirect to login page on token invalid/expired responses#14856
Merged
KomachiSion merged 1 commit intoApr 7, 2026
Merged
Conversation
Improve session expired detection in both legacy and next console UIs: - Add 'invalid signature' and other token-related error messages to session expired detection list - Check both 'message' and 'data' fields in error responses (the server wraps the real reason inside the 'data' field via AuthResult.format()) - Add session expired detection in success interceptor for cases where HTTP 200 is returned with business error code - Extract session expired messages into a shared constant in legacy UI - Add auto-copy of build artifacts to legacy UI build script Assisted-by: Kiro
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
KomachiSion
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
When the JWT token becomes invalid (e.g. after changing
nacos.core.auth.plugin.nacos.token.secret.keyand restarting), the backend returns HTTP 403 with{code: 10001, message: "access denied", data: "Code: 401, Message: Invalid signature."}. However, both the legacy and next console UIs fail to detect this as a session expiration and do not redirect to the login page.Root Cause
Legacy UI (
console-ui/src/utils/request.js): The error interceptor only checked themessagefield with strict equality against a small list (token invalid!,token expired!, etc.). The actual error message"access denied"didn't match, and thedatafield (which contains"Invalid signature") was never checked.Next UI (
console-ui-next/src/api/client.ts): The error interceptor checked bothmessageanddatafields, but the keyword list was missing"invalid signature"and other token-related error messages from the backend.Both UIs: The success interceptor had no session expiration detection at all, which is needed as a defensive measure in case the HTTP status code is not correctly set to 403.
Brief changelog
invalid signature,expired token,unsupported signature algorithm,user not found,token is required,token is empty,token has expired,token signature verification failedmessageanddata.datafields using case-insensitiveincludes()matching (previously used strict equality onmessageonly); extracted the keyword list into a shared constantSESSION_EXPIRED_MESSAGESconstantnpm run buildscript (consistent with next UI)How to verify
nacos.core.auth.plugin.nacos.token.secret.keyin the config and restart the serverFollow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check spotbugs:check -DskipTeststo make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.