Repository navigation
feat(console): add periodic password change policy card - #14602
Conversation
Adds a card to Auth → Policies → Passwords for the password rotation policy: a toggle plus a maximum age in days, weeks, months or years. `maxAge` is left out while the policy is off so the stored age is kept, and the card is hidden when the server reports no rotation policy.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
🧹 Nitpicks (1) — 🟢 1 low
The PR adds a password-rotation policy card under the project auth policies view, letting users toggle the policy and set a max age across days/weeks/months/years units, with an update mutation wired through React Query.
Reviewed commit: 675674b |
New ConsoleProject ID: Tip MCP server integration brings LLM superpowers to Claude Desktop and Cursor IDE |
🟢 Tier S · Ready to mergeAdds a password-rotation policy card to Auth → Policies → Passwords, with a configurable maximum age and an enable toggle. The policy is parsed from the project policy list, saved through the project SDK, included in policy search, and translated into Hebrew and Japanese.
📂 Walkthrough · 7
Reviewed |
There was a problem hiding this comment.
Adds a periodic password-rotation policy card to the Console auth settings with he/ja translations, a new update hook, and settings-search wiring.
Key findings
- 🟡 Unit switch reinterprets value instead of converting — PasswordRotationCard.tsx:150
| <Select | ||
| value={unit} | ||
| onValueChange={(value) => setUnit(value as TimeUnit)} | ||
| disabled={mutation.isPending || !enabled} |
There was a problem hiding this comment.
🟡 bug · medium
Unit switch reinterprets value instead of converting
The unit Select calls setUnit(value as TimeUnit) without converting the current number (PasswordRotationCard.tsx:152), so a typed value is silently reinterpreted in the new unit: entering 1 day and switching to years yields 1 year, and switching 3650 days to years pushes maxAgeSeconds far past MAX_MAX_AGE_SECONDS, flipping the card into its invalid state with a value the user never chose. Values that stay within bounds (1 day -> 1 year) pass validation and would be submitted as the wrong policy. The sibling SessionLengthCard has a dedicated handleUnitChange that converts, rounds, and clamps before switching.
📋 Prompt for AI Agents
In apps/console/src/components/pages/projects/$projectId/auth/policies/PasswordRotationCard.tsx around lines 150-153, replace onValueChange={(value) => setUnit(value as TimeUnit)} with a handler mirroring SessionLengthCard's handleUnitChange in src/components/pages/projects/$projectId/auth/Security.tsx: convert toSeconds(maxAge, unit), convert back with fromSeconds(currentSeconds, newUnit), round to a whole number, clamp to Math.floor(fromSeconds(MAX_MAX_AGE_SECONDS, newUnit)), then setMaxAge(clamped) and setUnit(newUnit). Without conversion, switching units silently reinterprets the typed number (1 day becomes 1 year) and can push the value outside the 1-day/10-years bounds.

What does this PR do?
Adds a Periodic password change card to Auth → Policies → Passwords for the password rotation policy from #14321, which could only be set through the API so far.
maxAgeis left out of the PATCH while the toggle is off, so turning the policy off keeps the stored age.password-rotationpolicy, like the breached-password and MFA cards.Test Plan
tsc --noEmitreports no errors in the changed files.Related PRs and Issues
Checklist