Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Add SiYuan branding to OAuth callback pages https://github.com/siyuan-note/siyuan/issues/18542

Danield34847be05c6
diff --git a/kernel/model/oidc_test.go b/kernel/model/oidc_test.go
index 7feb79cdce..730091efeb 100644
--- a/kernel/model/oidc_test.go
+++ b/kernel/model/oidc_test.go
@@ -442,7 +442,7 @@ func TestWriteOIDCCallbackPageUsesSharedOAuthStyle(t *testing.T) {
writeOIDCCallbackPage(context, false, "登录失败<script>")
page := recorder.Body.String()
- for _, expected := range []string{`lang="zh-CN"`, `class="mark mark--error"`, "登录失败&lt;script&gt;"} {
+ for _, expected := range []string{`lang="zh-CN"`, `class="brand">SiYuan</div>`, `class="mark mark--error"`, "登录失败&lt;script&gt;"} {
if !strings.Contains(page, expected) {
t.Fatalf("OIDC callback page does not contain %q: %s", expected, page)
}
diff --git a/kernel/util/oauth_callback.go b/kernel/util/oauth_callback.go
index cea69876da..ea4c543dad 100644
--- a/kernel/util/oauth_callback.go
+++ b/kernel/util/oauth_callback.go
@@ -28,9 +28,10 @@ func RenderOAuthCallbackPage(lang, title, message string, success bool) []byte {
`<meta name="viewport" content="width=device-width,initial-scale=1"><title>` + html.EscapeString(title) + `</title>` +
`<style>body{margin:0;min-height:100vh;display:grid;place-items:center;background:#f5f5f5;color:#202124;font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}` +
`main{box-sizing:border-box;width:min(480px,calc(100vw - 32px));padding:40px 32px;text-align:center;background:#fff;border:1px solid #ddd;border-radius:12px;box-shadow:0 8px 24px #00000014}` +
+ `.brand{margin:0 0 28px;font-size:28px;font-weight:700;letter-spacing:-.5px}` +
`.mark{display:grid;place-items:center;width:56px;height:56px;margin:0 auto 24px;border-radius:50%;background:#2e7d32;color:#fff;font-size:32px}.mark--error{background:#c62828}` +
`h1{margin:0 0 12px;font-size:24px;font-weight:600}p{margin:0;color:#5f6368;font-size:15px;line-height:1.7}` +
`@media(prefers-color-scheme:dark){body{background:#171717;color:#eee}main{background:#242424;border-color:#3c3c3c;box-shadow:none}p{color:#bbb}}</style>` +
- `</head><body><main><div class="mark` + markClass + `" aria-hidden="true">` + mark + `</div><h1>` + html.EscapeString(title) +
+ `</head><body><main><div class="brand">SiYuan</div><div class="mark` + markClass + `" aria-hidden="true">` + mark + `</div><h1>` + html.EscapeString(title) +
`</h1><p>` + html.EscapeString(message) + `</p></main></body></html>`)
}
diff --git a/kernel/util/oauth_callback_test.go b/kernel/util/oauth_callback_test.go
index b10b8b89ec..06910c8d34 100644
--- a/kernel/util/oauth_callback_test.go
+++ b/kernel/util/oauth_callback_test.go
@@ -23,7 +23,7 @@ import (
func TestRenderOAuthCallbackPage(t *testing.T) {
page := string(RenderOAuthCallbackPage("zh-CN", "已收到<script>", "返回思源 & 查看状态", true))
- for _, expected := range []string{`lang="zh-CN"`, "已收到&lt;script&gt;", "返回思源 &amp; 查看状态", `class="mark"`} {
+ for _, expected := range []string{`lang="zh-CN"`, "已收到&lt;script&gt;", "返回思源 &amp; 查看状态", `class="brand">SiYuan</div>`, `class="mark"`} {
if !strings.Contains(page, expected) {
t.Fatalf("OAuth callback page does not contain %q: %s", expected, page)
}