Repository navigation
feat(frontend): 完善认证入口与登录体验 (#69) - #114
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough本次变更扩展认证上下文的会话提示和登出进度状态,改进登录页校验、错误反馈、密码显示切换及加载状态,并更新应用外壳的登出按钮和相关测试。 Changes认证流程
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant LoginPage
participant AuthProvider
participant AuthenticationAPI
LoginPage->>LoginPage: 校验并整理凭据
LoginPage->>AuthProvider: 调用 login(email.trim(), password)
AuthProvider->>AuthenticationAPI: 发送登录请求
AuthenticationAPI-->>AuthProvider: 返回认证结果
AuthProvider-->>LoginPage: 更新认证状态和提示
sequenceDiagram
participant AppShell
participant AuthProvider
participant AuthenticationAPI
AppShell->>AuthProvider: 调用 logout()
AuthProvider->>AuthProvider: 设置 isLoggingOut
AuthProvider->>AuthenticationAPI: 发送登出请求
AuthenticationAPI-->>AuthProvider: 返回结果
AuthProvider-->>AppShell: 清除会话并恢复按钮状态
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/auth/AuthContext.tsx`:
- Around line 76-84: Update the logout implementation in AuthContext’s logout
function to consume failures from requestLogout(token) after attempting the
remote request, while preserving the finally behavior that always calls
clearSession() and resets isLoggingOut. Ensure logout resolves without
rethrowing the request failure so the void logout() callers in AppShell do not
produce unhandled Promise rejections.
In `@frontend/src/pages/LoginPage.tsx`:
- Around line 8-10: Update hasValidEmail in LoginPage.tsx to perform actual
email-format validation rather than only checking for an '@' character,
rejecting values such as a@, `@demo.invalid`, and addresses containing multiple
'@' characters while preserving valid email input behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 476af493-1ed7-47f4-804d-86aa27c41cdc
📒 Files selected for processing (7)
frontend/src/App.test.tsxfrontend/src/auth/AuthContext.test.tsxfrontend/src/auth/AuthContext.tsxfrontend/src/auth/auth-context.tsfrontend/src/components/AppShell.tsxfrontend/src/pages/LoginPage.test.tsxfrontend/src/pages/LoginPage.tsx
| function hasValidEmail(value: string) { | ||
| return value.trim().includes('@') | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
使用实际的邮箱格式校验。
由于表单设置了 noValidate,a@、@demo.invalid 或包含多个 @ 的值都会通过当前校验并发送登录请求,违反字段级校验预期。
建议修复
function hasValidEmail(value: string) {
- return value.trim().includes('@')
+ return /^[^\s@]+@[^\s@]+$/.test(value.trim())
}As per path instructions,frontend/** 需要关注输入校验与用户可见失败路径。
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function hasValidEmail(value: string) { | |
| return value.trim().includes('@') | |
| } | |
| function hasValidEmail(value: string) { | |
| return /^[^\s@]+@[^\s@]+$/.test(value.trim()) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@frontend/src/pages/LoginPage.tsx` around lines 8 - 10, Update hasValidEmail
in LoginPage.tsx to perform actual email-format validation rather than only
checking for an '@' character, rejecting values such as a@, `@demo.invalid`, and
addresses containing multiple '@' characters while preserving valid email input
behavior.
Source: Path instructions
内容
验证
Summary by CodeRabbit