:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(auth): help password managers recognize existing-password fields (#120890)
Eleftheria Trivyzaki14ef524360e1
diff --git a/frontend/src/lib/components/TimeSensitiveAuthentication/TimeSensitiveAuthentication.tsx b/frontend/src/lib/components/TimeSensitiveAuthentication/TimeSensitiveAuthentication.tsxindex 2687843b5239..641f71d45e77 100644--- a/frontend/src/lib/components/TimeSensitiveAuthentication/TimeSensitiveAuthentication.tsx+++ b/frontend/src/lib/components/TimeSensitiveAuthentication/TimeSensitiveAuthentication.tsx@@ -77,15 +77,29 @@ export function TimeSensitiveAuthenticationModal(): JSX.Element {enableFormOnSubmit>{!twoFactorRequired ? (- <LemonField name="password" label="Re-enter password">- <LemonInput- type="password"- className="ph-ignore-input"- data-attr="password"- autoComplete="current-password"- autoFocus+ // One child of the spaced form, so the hidden input does not push the password field down+ <div>+ {/* Password managers match a saved login by username, so a lone password field gets a generated password instead */}+ <input+ type="email"+ name="email"+ autoComplete="username"+ value={user?.email || ''}+ readOnly+ tabIndex={-1}+ aria-hidden+ className="sr-only"/>- </LemonField>+ <LemonField name="password" label="Password">+ <LemonInput+ type="password"+ className="ph-ignore-input"+ data-attr="password"+ autoComplete="current-password"+ autoFocus+ />+ </LemonField>+ </div>) : null}{twoFactorRequired ? (diff --git a/frontend/src/scenes/settings/user/ChangePassword.tsx b/frontend/src/scenes/settings/user/ChangePassword.tsxindex fdca5001de1c..7c09ac3baebe 100644--- a/frontend/src/scenes/settings/user/ChangePassword.tsx+++ b/frontend/src/scenes/settings/user/ChangePassword.tsx@@ -28,67 +28,66 @@ export function ChangePassword(): JSX.Element {const hasPassword = user?.has_password ?? falsereturn (- <Form- logic={changePasswordLogic}- formKey="changePassword"- enableFormOnSubmit- className="deprecated-space-y-4 max-w-160"- >- {hasPassword && (- <>- <LemonField- name="current_password"- label={- <div className="flex flex-1 items-center justify-between gap-2">- <span>Current password</span>- <LemonButton- size="xsmall"- type="tertiary"- data-attr="settings-forgot-password"- onClick={requestPasswordResetEmail}- loading={passwordResetEmailSentLoading}- >- {passwordResetEmailSent ? 'Resend link' : 'Forgot password?'}- </LemonButton>- </div>- }- >- <LemonInput- autoComplete="current-password"- type="password"- className="ph-ignore-input"- placeholder="••••••••••"- />- </LemonField>-- {passwordResetEmailSent && (- <LemonBanner type="info">- We emailed a reset link to <span translate="no">{user?.email}</span>. Open it to set a new- password without your current one. Resetting signs you out of PostHog on every device.- </LemonBanner>- )}- </>- )}+ <Form logic={changePasswordLogic} formKey="changePassword" enableFormOnSubmit className="max-w-160">+ {/* Password managers match a saved login by username, so without one they offer a generated password for the current password too */}+ <input+ type="email"+ name="email"+ autoComplete="username"+ value={user?.email || ''}+ readOnly+ tabIndex={-1}+ aria-hidden+ className="sr-only"+ />+ {/* Spacing lives on this wrapper so the hidden input above does not push the first field down */}+ <div className="deprecated-space-y-4">+ {hasPassword && (+ <>+ <LemonField+ name="current_password"+ label={+ <div className="flex flex-1 items-center justify-between gap-2">+ <span>Current password</span>+ <LemonButton+ size="xsmall"+ type="tertiary"+ data-attr="settings-forgot-password"+ onClick={requestPasswordResetEmail}+ loading={passwordResetEmailSentLoading}+ >+ {passwordResetEmailSent ? 'Resend link' : 'Forgot password?'}+ </LemonButton>+ </div>+ }+ >+ <LemonInput+ autoComplete="current-password"+ type="password"+ className="ph-ignore-input"+ placeholder="••••••••••"+ />+ </LemonField>- <LemonField- name="password"- label={- <div className="flex flex-1 items-center justify-between">- <span>Password</span>- <PasswordStrength validatedPassword={validatedPassword} />- </div>- }- >- <LemonInput- autoComplete="new-password"- type="password"- className="ph-ignore-input"- placeholder="••••••••••"- />- </LemonField>+ {passwordResetEmailSent && (+ <LemonBanner type="info">+ We emailed a reset link to <span translate="no">{user?.email}</span>. Open it to set a+ new password without your current one. Resetting signs you out of PostHog on every+ device.+ </LemonBanner>+ )}+ </>+ )}- {!hasPassword && (- <LemonField name="confirm_password" label="Confirm password">+ <LemonField+ name="password"+ label={+ <div className="flex flex-1 items-center justify-between">+ <span>Password</span>+ <PasswordStrength validatedPassword={validatedPassword} />+ </div>+ }+ ><LemonInputautoComplete="new-password"type="password"@@ -96,11 +95,22 @@ export function ChangePassword(): JSX.Element {placeholder="••••••••••"/></LemonField>- )}- <LemonButton type="primary" htmlType="submit" loading={isChangePasswordSubmitting}>- {hasPassword ? 'Change password' : 'Set password'}- </LemonButton>+ {!hasPassword && (+ <LemonField name="confirm_password" label="Confirm password">+ <LemonInput+ autoComplete="new-password"+ type="password"+ className="ph-ignore-input"+ placeholder="••••••••••"+ />+ </LemonField>+ )}++ <LemonButton type="primary" htmlType="submit" loading={isChangePasswordSubmitting}>+ {hasPassword ? 'Change password' : 'Set password'}+ </LemonButton>+ </div></Form>)}