Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(mfa): keep OAuth status visible as a read-only card
Elian Doran8ed7dc3478d6
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 12d79e3a61..dc4e98ee38 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1746,6 +1746,8 @@"recovery_keys_dot_available": "Available","recovery_keys_dot_used": "Used on {{date}}","oauth_title": "OAuth/OpenID",+ "oauth_status_configured": "Configured",+ "oauth_status_not_configured": "Not configured","oauth_description": "OpenID is a standardized way to let you log into websites using an account from another service, like Google, to verify your identity. The default issuer is Google, but you can change it to any other OpenID provider. Check <a href=\"#root/_hidden/_help/_help_Otzi9La2YAUX/_help_WOcw2SLH6tbX/_help_7DAiwaf8Z7Rz\">here</a> for more information. Follow these <a href=\"https://developers.google.com/identity/openid-connect/openid-connect\">instructions</a> to setup an OpenID service through Google.","oauth_description_warning": "To enable OAuth/OpenID, you need to set the OAuth/OpenID base URL, client ID and client secret in the config.ini file and restart the application. If you want to set from environment variables, please set TRILIUM_OAUTH_BASE_URL, TRILIUM_OAUTH_CLIENT_ID and TRILIUM_OAUTH_CLIENT_SECRET.","oauth_missing_vars": "Missing settings: {{-variables}}",diff --git a/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.css b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.cssindex fb64e5afb7..dcef53e83d 100644--- a/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.css+++ b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.css@@ -20,6 +20,24 @@--color: var(--muted-text-color, #888);}+/* OAuth section heading: the title text and its configured/not-configured status badge on one line,+ the badge sitting just after the title. */+.oauth-status-title {+ display: inline-flex;+ align-items: center;+ gap: 10px;+}++/* Status badge mirrors the page-header MFA badge: a colored outline whose hue is driven by --color+ (green when configured, muted otherwise). */+.oauth-status-badge.configured {+ --color: var(--admonition-tip-accent-color, #40c025);+}++.oauth-status-badge.not-configured {+ --color: var(--muted-text-color, #888);+}+/* Keeps the "Recovery codes" label text and its dots on one line, the dots sitting just after thetitle. Lives inside the row's <label>, so text and dots share one box and stay aligned. */.recovery-codes-title {diff --git a/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsx b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsxindex ab0df2df40..ac5e4a6ebc 100644--- a/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsx+++ b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsx@@ -116,9 +116,12 @@ function MultiFactorMethod({ mfaMethod, setMfaMethod, totpStatus, oauthStatus, r</FormText></OptionsSection>}- { mfaMethod === "totp"- ? <TotpSettings totpStatus={totpStatus} refreshTotpStatus={refreshTotpStatus} />- : <OAuthSettings status={oauthStatus} /> }+ { mfaMethod === "totp" &&+ <TotpSettings totpStatus={totpStatus} refreshTotpStatus={refreshTotpStatus} /> }++ {/* OAuth is configured entirely server-side, so its card is read-only and stays visible+ regardless of the active method — it's a status indicator for whether OAuth is available. */}+ <OAuthStatusCard status={oauthStatus} /></>);}@@ -634,17 +637,41 @@ function formatRecoveryCodeUsedDate(statusEntry: string) {return isNaN(date.getTime()) ? statusEntry : date.toLocaleString();}-function OAuthSettings({ status }: { status?: OAuthStatus }) {+/**+ * Read-only OAuth/OpenID status card. OAuth is configured entirely server-side (env vars / config.ini),+ * so this card offers no controls — it just reflects whether OAuth is available, and when it's the+ * active method, the signed-in account. It stays visible even while TOTP is the active method so the+ * user can always tell whether OAuth is set up.+ */+function OAuthStatusCard({ status }: { status?: OAuthStatus }) {+ // "Configured" is purely about the server-side variables being present, independent of which MFA+ // method is currently active (the server's `enabled` flag additionally requires mfaMethod === 'oauth').+ const configured = (status?.missingVars?.length ?? 1) === 0;+return (- <OptionsSection title={t("multi_factor_authentication.oauth_title")}>- { status?.enabled ? (+ <OptionsSection+ title={+ <span className="oauth-status-title">+ {t("multi_factor_authentication.oauth_title")}+ <Badge+ className={`oauth-status-badge ${configured ? "configured" : "not-configured"}`}+ icon={configured ? "bx bx-check" : "bx bx-x"}+ text={configured+ ? t("multi_factor_authentication.oauth_status_configured")+ : t("multi_factor_authentication.oauth_status_not_configured")}+ outline+ />+ </span>+ }+ >+ { configured ? (<div class="col-md-6"><span><b>{t("multi_factor_authentication.oauth_user_account")}</b></span>- <span class="user-account-name">{status.name ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span>+ <span class="user-account-name">{status?.name ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span><br /><span><b>{t("multi_factor_authentication.oauth_user_email")}</b></span>- <span class="user-account-email">{status.email ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span>+ <span class="user-account-email">{status?.email ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span></div>) : (<>