Repository navigation
fix: align password-protection vocabulary in v3 (unlock, not login) - #3404
Conversation
Ports the vocabulary changes from v4 (f4ed151) to v3 to fix the cookie name inconsistency (`__fs_auth_token` → `__fs_password_protection`) and align all related identifiers, file names, URLs, and UI copy. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
🛡️ SDD Check — action requiredI couldn't detect an SDD in this PR. Please check one option below (requires write access to the repo):
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRenames ChangesPassword Protection Rename
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/server/password-protection-service.ts (1)
264-273: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLeftover
loginUrlname in renamed helper.Since this PR is all about unifying the
unlock/password-protectionvocabulary, the localloginUrlinsideredirectToUnlockPageis the last bit ofloginlingo hiding out. Renaming it keeps the helper internally consistent.♻️ Proposed rename
private redirectToUnlockPage(request: NextRequest): NextResponse { - const loginUrl = new URL('/password-protection', request.url) + const unlockUrl = new URL('/password-protection', request.url) const returnTo = `${request.nextUrl.pathname}${request.nextUrl.search}` - loginUrl.searchParams.set('returnTo', returnTo) + unlockUrl.searchParams.set('returnTo', returnTo) - const response = NextResponse.redirect(loginUrl) + const response = NextResponse.redirect(unlockUrl) response.headers.set('Cache-Control', 'no-store') return response }🤖 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 `@packages/core/src/server/password-protection-service.ts` around lines 264 - 273, The local variable `loginUrl` in the `redirectToUnlockPage` method uses "login" terminology which conflicts with the PR's vocabulary unification to use "unlock"/"password-protection" terms. Rename the `loginUrl` variable to `unlockUrl` throughout the method to maintain internal consistency with the method name and the overall vocabulary changes in this PR.
🤖 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.
Nitpick comments:
In `@packages/core/src/server/password-protection-service.ts`:
- Around line 264-273: The local variable `loginUrl` in the
`redirectToUnlockPage` method uses "login" terminology which conflicts with the
PR's vocabulary unification to use "unlock"/"password-protection" terms. Rename
the `loginUrl` variable to `unlockUrl` throughout the method to maintain
internal consistency with the method name and the overall vocabulary changes in
this PR.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 23ebfbaf-5aa9-4513-9d4a-5fa9430ab391
📒 Files selected for processing (7)
packages/core/src/middleware.tspackages/core/src/pages/api/fs/password-protection/unlock.tspackages/core/src/pages/password-protection/index.tsxpackages/core/src/pages/password-protection/password-protection.module.scsspackages/core/src/server/password-protection-service.tspackages/core/src/utils/unlockResponse.tspackages/core/test/server/password-protection-service.test.ts
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@faststore/api
@faststore/cli
@faststore/components
@faststore/core
@faststore/graphql-utils
@faststore/lighthouse
@faststore/sdk
@faststore/ui
commit: |
renatomaurovtex
left a comment
There was a problem hiding this comment.
Review — fix: align password-protection vocabulary in v3 (unlock, not login) (base 3.x)
Reviewed the full diff. This is a faithful backport of the v4 #3276 vocabulary refactor to v3: rename AuthenticationService→PasswordProtectionService, authenticateRequest→checkStoreProtection, handleNoAuth→handleProtectionCheck, redirectToLogin→redirectToUnlockPage, the /fs-auth-login→/password-protection page + /api/fs/auth/login→/api/fs/password-protection/unlock API routes, and the critical cookie rename __fs_auth_token→__fs_password_protection. Tests were renamed and all cookie/redirect assertions updated to the new names, and the middleware matcher exclusion was updated in lockstep (fs-auth-login→password-protection). The fail-close-to-unlock behavior is preserved across every branch (status fetch fail, non-ok, expired-renew fail). Mechanically clean and well-covered.
🟠 Cookie rename invalidates live protection sessions on deploy
Renaming __fs_auth_token→__fs_password_protection means every shopper currently holding a valid __fs_auth_token is treated as unauthenticated on the first request after deploy and bounced to /password-protection. The renew/status flow immediately re-issues the new cookie, so it's a one-time re-unlock, not a loop — but it IS a visible UX blip for protected stores. Please call this out in the release notes for the v3 line.
🟠 External-consumer coordination (the actual motivation)
The PR rationale is that an external app reads this cookie by name. The rename only fixes the inconsistency if that consumer is updated to read __fs_password_protection (or both names during a transition) and deployed around the same time. Otherwise this rename breaks the consumer in the opposite direction. Confirm the consuming app's rollout is sequenced with this merge.
🟡 isUnlockResponse adds stricter validation (not a pure rename)
Beyond the rename, isUnlockResponse now requires hasUnlockResponseField (at least one of success/redirectUrl/error defined), so an empty {} body that previously passed isLoginResponse now fails → the unlock page shows "Service temporarily unavailable". This looks intentional (an empty body isn't a meaningful unlock response, and the handler returns {success, redirectUrl} on success / {error} on failure), but it's a behavior change worth confirming matches the v4 #3276 implementation byte-for-byte so v3/v4 stay aligned.
💬 Nits
- The page component is still named
PasswordProtectionLogin(function identifier) though everything else moved off "login" — cosmetic, default export so no external impact. redirectToUnlockPagekeepsCache-Control: no-storeon the redirect — correct, preserved.
CI: FastStore build/test + codesandbox green; UI Tests pending (Chromatic baselines to accept — expected for the SCSS class rename).
Verdict: Approved with comments. No code blockers — the gating items are operational: sequence the external consumer + cookie-rename and note the one-time re-unlock in the v3 release notes.
FAS-1151
Summary
__fs_auth_token→__fs_password_protection(the critical fix)unlockdomainChanges
__fs_auth_token(cookie)__fs_password_protectionAuthenticationServicePasswordProtectionServiceauthenticateRequest()checkStoreProtection()authentication-service.tspassword-protection-service.tsloginResponse.tsunlockResponse.tsLoginResponse/isLoginResponseUnlockResponse/isUnlockResponsepages/api/fs/auth/loginpages/api/fs/password-protection/unlockpages/fs-auth-login/pages/password-protection/LoginUnlockfs-auth-passwordpassword-protection-inputContext
The vocabulary inconsistency between v3 and v4 was causing issues in another application reading the auth cookie by name. This PR brings v3 in sync with the v4 refactor that was already merged (#3276).
Test plan
pnpm testinpackages/core)/password-protectionwhen store is protected/api/fs/password-protection/unlockand sets__fs_password_protectioncookie on success🤖 Generated with Claude Code
Summary by CodeRabbit
Summary by CodeRabbit
Release Notes