Skip to content

Commit 46af001

Browse files
os-zhuangclaude
andauthored
fix(app-shell): don't show recovery-password reminder on SSO-enforced envs (#2184)
The RecoveryPasswordReminder nudges the user to set a local recovery password "so you can still sign in if SSO is ever unavailable". But on an SSO-enforced env, password login is DISABLED (LoginForm already hides the password field) — so a recovery password can't actually be used. Showing the nudge there is misleading and gives a false sense of security (set one, SSO goes down, still locked out). Gate the reminder on password-login availability using the same signal LoginForm reads from getAuthConfig(): features.ssoEnforced === true || emailPassword.enabled === false. Only show when a password fallback is actually usable. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f32979d commit 46af001

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

packages/app-shell/src/console/home/HomePage.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function PendingDraftsBanner({ t }: { t: (key: string, opts?: any) => string })
184184
*/
185185
function RecoveryPasswordReminder({ t }: { t: (key: string, opts?: any) => string }) {
186186
const navigate = useNavigate();
187-
const { hasLocalPassword } = useAuth();
187+
const { hasLocalPassword, getAuthConfig } = useAuth();
188188
const [show, setShow] = useState(false);
189189
useEffect(() => {
190190
if (typeof localStorage !== 'undefined' && localStorage.getItem('os:recovery-pw-dismissed') === '1') return;
@@ -198,11 +198,22 @@ function RecoveryPasswordReminder({ t }: { t: (key: string, opts?: any) => strin
198198
return;
199199
}
200200
let cancelled = false;
201-
Promise.resolve(hasLocalPassword?.())
202-
.then((has) => { if (!cancelled && has === false) setShow(true); })
201+
Promise.all([
202+
Promise.resolve(hasLocalPassword?.()),
203+
Promise.resolve(getAuthConfig?.()).catch(() => null),
204+
])
205+
.then(([has, config]: [unknown, any]) => {
206+
if (cancelled) return;
207+
// Skip on SSO-enforced envs: password login is disabled there, so a
208+
// recovery password can't be used — nudging for one is misleading and
209+
// gives a false sense of security. Same signal LoginForm uses.
210+
const passwordUnavailable =
211+
config?.features?.ssoEnforced === true || config?.emailPassword?.enabled === false;
212+
if (has === false && !passwordUnavailable) setShow(true);
213+
})
203214
.catch(() => { /* unknown → don't nag */ });
204215
return () => { cancelled = true; };
205-
}, [hasLocalPassword]);
216+
}, [hasLocalPassword, getAuthConfig]);
206217
const dismiss = () => {
207218
try { localStorage.setItem('os:recovery-pw-dismissed', '1'); } catch { /* ignore */ }
208219
setShow(false);

0 commit comments

Comments
 (0)