Redirect unauthorized users to /login#1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a44cee98a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if matches!(self, AppError::Unauthorized) { | ||
| return Redirect::to("/login").into_response(); | ||
| } |
There was a problem hiding this comment.
Keep API auth failures as 401 instead of redirecting
This unconditional redirect changes every AppError::Unauthorized into a 303 /login, including API handlers in src/routes/api.rs that call auth::require_admin. Because fetch follows redirects, the admin frontend (static/admin-app.js) receives a 200 HTML login page and then fails at response.json() (or misclassifies auth loss as a generic parse error) when a session expires, instead of getting a clean 401 auth failure signal.
Useful? React with 👍 / 👎.
Motivation
Description
src/error.rssoAppError::into_responsereturnsRedirect::to("/login")forAppError::Unauthorized, and add theRedirectimport fromaxum::response.Testing
cargo fmt --allandcargo check, both completed successfully.Codex Task