tju-yxq opened a new pull request, #5246:
URL: https://github.com/apache/rocketmq-dashboard/pull/5246
### Which Issue(s) This PR Fixes
- Fixes #5245
### Brief Description
When a session expires mid-work, the 401 handler now carries the current
path and query string to the login page as an encoded `?redirect=` parameter (a
plain `/login` when the session expired while already there), and after a
successful login the page navigates back to that target with replace
navigation. The target is validated before use — only same-app absolute paths
are accepted; protocol-relative URLs, absolute external URLs, paths without a
leading slash and backslash tricks fall back to home, so the parameter cannot
be turned into an open redirect.
### How Did You Test This Change?
Run on the branch (`2eaf95f7`, based on `master` @ `0228dad5`):
```
cd web && npm test -- login --run
Test Files 2 passed (2)
Tests 10 passed (10)
cd web && npm run lint
0 errors (11 pre-existing warnings in unrelated files)
```
New coverage (`web/src/pages/login/redirect.test.tsx`): a login with
`?redirect=%2Fops%2Falerts%3Flevel%3Derror` navigates back to
`/ops/alerts?level=error` with replace; a login without the parameter still
navigates to `/`; and four rejected shapes — protocol-relative, absolute
external, no leading slash, backslash — each fall back to `/`. The existing
login tests (brand render, submit flow, in-flight guard, validation) keep
passing unchanged.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(no new UI text in this change)
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [x] New source files carry the ASF license header
- [ ] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]