fix(auth): honor SSO-only CLI recovery without restart (#1810)

This commit is contained in:
Anso
2026-08-09 23:48:44 -04:00
committed by GitHub
parent 55ca82abb2
commit 27fe0ae837
9 changed files with 86 additions and 19 deletions
+8 -2
View File
@@ -6,9 +6,15 @@ export type AuthenticationMode = (typeof AUTHENTICATION_MODES)[number];
export const AUTHENTICATION_MODE_KEY = 'authentication_mode';
export const DEFAULT_AUTHENTICATION_MODE: AuthenticationMode = 'local_and_sso';
/** Read the cached global setting; missing or unknown values default to local_and_sso. */
/**
* Read authentication_mode with a fresh SQLite lookup. Must not use the
* getGlobalSettings() process cache: enableLocalLogin / disableSso write this
* key from a sidecar CLI process, and a stale sso_only cache would keep
* rejecting local password login after recovery until Sencho restarts.
* Missing or unknown values default to local_and_sso.
*/
export function getAuthenticationMode(db: DatabaseService = DatabaseService.getInstance()): AuthenticationMode {
const raw = db.getGlobalSettings()[AUTHENTICATION_MODE_KEY];
const raw = db.getGlobalSettingFresh(AUTHENTICATION_MODE_KEY);
if (raw === 'sso_only') return 'sso_only';
return DEFAULT_AUTHENTICATION_MODE;
}