Secure admin login flow

This commit is contained in:
Codex
2026-04-28 09:16:15 +08:00
parent 21cb5c9c15
commit 98e32a4385
15 changed files with 646 additions and 0 deletions
+2
View File
@@ -47,6 +47,7 @@ Optional variables:
12. Run `npm run payload:migrate:status` and confirm every migration is `Yes`.
13. Start the app with `npm run start`.
14. Run `npm run smoke -- "$NEXT_PUBLIC_SITE_URL"`.
15. Log out of the admin, open `/admin/login`, and confirm the verification code is required before password validation.
## Data Rules
@@ -56,6 +57,7 @@ Optional variables:
- Do not edit migrations after they have shipped to production. Add a new forward migration instead.
- Keep schema migrations and data backfills separate. Backfill scripts in `src/scripts/` are manual operational tools, not automatic boot steps.
- The deployed database and upload directories must come from the same local export, otherwise media relationships can point at missing files.
- Admin login captcha is stateless and signed with `PAYLOAD_SECRET`; changing that secret invalidates existing login sessions and outstanding captcha tokens.
## Rollback
@@ -190,6 +190,7 @@ npm run start
```bash
curl -f "$NEXT_PUBLIC_SITE_URL/api/health"
curl -f "$NEXT_PUBLIC_SITE_URL/api/admin/captcha"
npm run smoke -- "$NEXT_PUBLIC_SITE_URL"
```
@@ -205,8 +206,11 @@ npm run smoke -- "$NEXT_PUBLIC_SITE_URL"
/en/support/tutorial
/en/dealers
/admin
/admin/login
```
后台上线后再手工确认一次:退出登录,打开 `/admin/login`,验证码错误时应该直接失败,验证码正确但密码错误时才进入账号密码校验。
## 8. 回滚
回滚要成套回滚:
+3
View File
@@ -12,6 +12,7 @@ Use this checklist before every production deployment.
- [ ] `npm run build` passes.
- [ ] `npm run payload:migrate:status` shows all migrations as `Yes` on the release database.
- [ ] `payload_migrations` has no `batch = -1` dev marker before exporting/importing the database.
- [ ] Admin login shows a verification code, invalid captcha fails before password validation, and `/admin` redirects to `/admin/login` when logged out.
- [ ] No new user-facing fallback copy was introduced without a CMS field.
## Environment
@@ -51,7 +52,9 @@ Required manual spot checks:
- `/en/support`
- `/en/support/tutorial`
- `/admin`
- `/admin/login`
- `/api/health`
- `/api/admin/captcha`
## Launch Notes