Skip to content

Build your personal knowledge base with Trilium Notes

fix(oauth): make the OpenID card badge reflect connection state

Elian Doranaf88b5e2f9a6
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 99af817639..f2819b0437 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1739,7 +1739,8 @@
"recovery_keys_dot_available": "Available",
"recovery_keys_dot_used": "Used on {{- date}}",
"oauth_title": "OpenID Connect",
- "oauth_status_configured": "Configured",
+ "oauth_status_connected": "Connected",
+ "oauth_status_not_connected": "Not connected",
"oauth_status_not_configured": "Not configured",
"oauth_description": "OpenID Connect lets you log in 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 Connect 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 set up an OpenID Connect service through Google.",
"oauth_not_configured_hint": "Let people sign in with an account from another service, like Google. Set OpenID Connect up on the server to enable it as a login method.",
diff --git a/apps/client/src/widgets/type_widgets/options/password.css b/apps/client/src/widgets/type_widgets/options/password.css
index 2615a1a109..096742f835 100644
--- a/apps/client/src/widgets/type_widgets/options/password.css
+++ b/apps/client/src/widgets/type_widgets/options/password.css
@@ -6,12 +6,16 @@
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 {
+/* Status badge mirrors the page-header MFA badge: a colored outline whose hue is driven by --color.
+ Three states: connected (green), configured-but-not-connected (amber), not configured (muted). */
+.oauth-status-badge.connected {
--color: var(--admonition-tip-accent-color, #40c025);
}
+.oauth-status-badge.not-connected {
+ --color: var(--admonition-warning-accent-color, #e0a800);
+}
+
.oauth-status-badge.not-configured {
--color: var(--muted-text-color, #888);
}
diff --git a/apps/client/src/widgets/type_widgets/options/password.tsx b/apps/client/src/widgets/type_widgets/options/password.tsx
index 5b649ad932..09806b577f 100644
--- a/apps/client/src/widgets/type_widgets/options/password.tsx
+++ b/apps/client/src/widgets/type_widgets/options/password.tsx
@@ -251,6 +251,15 @@ function OAuthStatusCard({ status, refreshStatus }: { status?: OAuthStatus, refr
const configured = (status?.missingVars?.length ?? 1) === 0;
const enrolled = status?.enrolled ?? false;
+ // The status badge mirrors the card's three states: an account is bound (green "Connected"),
+ // the server is set up but no account is bound yet (amber "Not connected"), or the server-side
+ // variables are missing entirely (muted "Not configured").
+ const badge = enrolled
+ ? { className: "connected", icon: "bx bx-check", text: t("multi_factor_authentication.oauth_status_connected") }
+ : configured
+ ? { className: "not-connected", icon: "bx bx-link", text: t("multi_factor_authentication.oauth_status_not_connected") }
+ : { className: "not-configured", icon: "bx bx-x", text: t("multi_factor_authentication.oauth_status_not_configured") };
+
// Enrollment is a full-page provider round-trip (not an XHR): navigate to the OIDC login route,
// which on return binds the identity to this still-authenticated session (see open_id afterCallback).
const connectAccount = useCallback(() => {
@@ -273,11 +282,9 @@ function OAuthStatusCard({ status, refreshStatus }: { status?: OAuthStatus, refr
<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")}
+ className={`oauth-status-badge ${badge.className}`}
+ icon={badge.icon}
+ text={badge.text}
outline
/>
</span>