Skip to content

feat(account-panel): add authentication dialog - #165

Merged
huyanxius merged 5 commits into
1024XEngineer:mainfrom
huyanxius:feat/159-account-panel-submit
Aug 7, 2026
Merged

feat(account-panel): add authentication dialog#165
huyanxius merged 5 commits into
1024XEngineer:mainfrom
huyanxius:feat/159-account-panel-submit

Conversation

@huyanxius

@huyanxius huyanxius commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

功能说明

  • 增加由 ?account=login 驱动的登录/注册面板,默认提供邮箱验证码免密登录。
  • 保留密码登录和注册入口,覆盖发码冷却、输入校验、错误保留与重复提交保护。
  • 登录完成后安全返回原站内路径,拒绝站外、协议相对和反斜杠形式的 returnTo
  • 桌面与 375px 窄屏均完成真实 UI 验证。

实现方式

  • 账号面板由 AppShell 常驻挂载,仅在查询参数精确为 account=login 时读取会话 Context。
  • 发码冷却按规范化邮箱记录,切换登录/注册模式不会绕过同一邮箱的 60 秒限制。
  • 安全回跳集中在 shared/navigation,只接受当前 origin 下的绝对站内路径。

截图

以下截图统一为 1280 × 720 横屏完整页面。

邮箱验证码登录

邮箱验证码登录横屏完整页面

密码登录

密码登录横屏完整页面

注册

注册横屏完整页面

验证

分支已更新到包含 PR #163 的最新 main,本地重新执行:

  • npm run format:check:通过。
  • npm run lint:通过。
  • npm run typecheck:通过。
  • npm run test:23 个文件、134 项测试通过;包含提交中关闭面板后不再跳转的回归测试。
  • npm run build:通过,Vite 转换 109 个模块。
  • 浏览器:验证码登录、密码登录、注册、安全回跳、错误保留和 375 × 812 响应式布局通过。
  • 干净上下文独立验收:通过,无阻断项。

截图与交互使用本地认证桩验证,不代表已完成真实后端联调。

范围边界

Closes #159

关联:#157、PR #163

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
windup Ready Ready Preview Aug 7, 2026 7:24am

Account flows need to preserve internal destinations without permitting external redirects.

Add a same-origin path sanitizer that rejects non-rooted, protocol-relative, and backslash forms.

Login flows can now reuse a narrow, tested return-path boundary.
The existing session actions had no query-driven interface for users to sign in or register.

Add code login, password login, registration, cooldown, validation, inline feedback, and safe return navigation.

The application shell now hosts the dialog while its closed state remains independent of auth context.
The account dialog should appear as a lightweight layer over the current page.

Add restrained backdrop and panel entry motion with the existing application timing language.

Reduced-motion users continue to receive the same interface without animation.
@huyanxius
huyanxius force-pushed the feat/159-account-panel-submit branch from e03c8cc to 4c00299 Compare August 7, 2026 06:55
@huyanxius
huyanxius marked this pull request as ready for review August 7, 2026 06:56
@huyanxius

Copy link
Copy Markdown
Collaborator Author

@nighca 老师,已基于最新 main 完成 rebase,CI 已通过

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: the async submit path does not check whether the dialog is still mounted after the await. Closing the panel while a login/register request is in flight can still call setSuccess and schedule the redirect, so a dismissed modal may navigate the page later.

Verification gap: I could not run the frontend tests in this workspace because the local node modules are not installed.

Comment thread frontend/src/features/account-panel/index.tsx
Pending authentication can finish after the account dialog has closed.

Track dismissal across close and unmount before continuing the async submit flow.

Closed dialogs no longer show success state or schedule a delayed navigation.
The async close race lacked a regression case.

Resolve a deferred code login after dismissing the dialog and advance the redirect timer.

The route now remains unchanged after the abandoned submission completes.
@huyanxius

Copy link
Copy Markdown
Collaborator Author

Medium: the async submit path does not check whether the dialog is still mounted after the await. Closing the panel while a login/register request is in flight can still call setSuccess and schedule the redirect, so a dismissed modal may navigate the page later.

Verification gap: I could not run the frontend tests in this workspace because the local node modules are not installed.

@fennoai 这个问题成立,已经修复。现在账号面板关闭或卸载后会终止异步提交的后续处理,请求随后成功或失败都不会再更新弹窗状态或安排跳转。
同时补了回归测试,覆盖“提交中关闭弹窗,等待请求完成并经过原定跳转时间后仍停留在当前页面”。聚焦测试 12/12、全量 134 项测试及 CI、Vercel 均已通过。你可以再检查

@fennoai

fennoai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

结论

这次修复成立。

  • frontend/src/features/account-panel/index.tsx:81-136, 185-210 新增了 dismissedRef,并在关闭/卸载时置位;提交成功后也会先检查该标记,关闭后的异步返回不会再写入状态或安排跳转。
  • frontend/src/features/account-panel/index.test.tsx:179-195 新增了回归测试,覆盖“提交中关闭面板,等请求完成并推进原定 900ms 跳转窗口后仍停留在当前页面”。

我本地尝试跑 npm test -- --run frontend/src/features/account-panel/index.test.tsx,但当前工作区里的 vitest 可执行入口返回 Permission denied,所以这一步没法在这里重新验证。

@huyanxius

Copy link
Copy Markdown
Collaborator Author

@nighca 老师,目前所有问题均已修复,可以 review 了

@huyanxius
huyanxius merged commit 5048d1a into 1024XEngineer:main Aug 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 实现登录与注册界面(Refs #157)

3 participants