fix: trigger browser password save prompt on password change

Safari, Chrome, and Firefox only offer to save passwords when they see
a real form submission with page navigation, not fetch() + redirect.

After the change-password API call succeeds, dynamically create a form
with the username and new password (autocomplete=username + new-password),
POST it to "/" causing a real navigation. The browser detects the form
submission with credential fields and prompts to save.

Also make the username field visible (read-only) on the change-password
page since Safari ignores hidden inputs for password detection, and add
autocomplete attributes to the login page fields.
This commit is contained in:
Siddharth Kumar Sah
2026-03-28 14:24:13 +08:00
parent 006b7c4509
commit 565b4805c7
2 changed files with 61 additions and 10 deletions
+4
View File
@@ -57,6 +57,8 @@ export function LoginPage() {
<input
id="username"
type="text"
name="username"
autoComplete="username"
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Enter username"
@@ -71,6 +73,8 @@ export function LoginPage() {
<input
id="password"
type="password"
name="password"
autoComplete="current-password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="Enter your password"