Auth UX: Implement automatic Login redirect on 401 Unauthorized API responses

未关闭
#303 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清

调研方向

未指定前端文件或测试。首先定位全局 Axios 配置和 router 入口点,然后追踪客户端凭据的存储和清除方式。当 401 清除会话并将用户重定向到 /login,且 UI 不会卡住时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

🔍 Problem Statement

When JWT tokens expire, API requests fail silently with 401 Unauthorized responses. Because there is currently no global handling for these responses, the frontend leaves the user in a broken UI state (e.g., empty dashboards, unresponsive action elements, or persistent loading states) without any feedback or session recovery.

🌟 Feature Description

We need to implement automatic and graceful handling of 401 responses on the frontend to improve the Auth UX. This can be achieved by adding a global Axios response interceptor that intercepts 401 Unauthorized errors from API requests.

🎯 Proposed Solution & Implementation Details

  1. Axios Interceptor: Add/update a global Axios response interceptor that catches any response with a status code of 401.
  2. Clear Client-Side Credentials: Upon detecting a 401, clear all relevant auth storage (e.g., JWT tokens, user profiles from localStorage/sessionStorage or cookies) to reset the client session state.
  3. Automatic Redirect: Trigger a clean, router-based redirect to /login so the user can easily re-authenticate and restore their session.
  • I agree to follow this project's Code of Conduct
主要语言
Python
星标
103
派生
143
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AOSSIE-Org/Devr.AI 的其他 Issue

查看 AOSSIE-Org/Devr.AI 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。