From cfe155a63ff5c07a1919d596d032bdf4ec1642c9 Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 2 Mar 2026 13:02:19 -0800 Subject: [PATCH] feat(admin-ui): support local and OIDC on one login page --- weed/admin/view/layout/layout.templ | 66 ++++++++++++++++---------- weed/admin/view/layout/layout_templ.go | 48 ++++++++++++++----- 2 files changed, 78 insertions(+), 36 deletions(-) diff --git a/weed/admin/view/layout/layout.templ b/weed/admin/view/layout/layout.templ index 359bb1b1a..cf10f5205 100644 --- a/weed/admin/view/layout/layout.templ +++ b/weed/admin/view/layout/layout.templ @@ -359,7 +359,7 @@ templ Layout(view ViewContext, content templ.Component) { } -templ LoginForm(title string, errorMessage string, csrfToken string) { +templ LoginForm(title string, errorMessage string, csrfToken string, localAuthEnabled bool, oidcAuthEnabled bool) { @@ -389,32 +389,50 @@ templ LoginForm(title string, errorMessage string, csrfToken string) { } -
- -
- -
- - - - + if localAuthEnabled { + + +
+ +
+ + + + +
-
- -
- -
- - - - + +
+ +
+ + + + +
+ + + + } + + if localAuthEnabled && oidcAuthEnabled { +
or
+ } + + if oidcAuthEnabled { + + Sign in with OIDC + + } + + if !localAuthEnabled && !oidcAuthEnabled { + - - - + }
diff --git a/weed/admin/view/layout/layout_templ.go b/weed/admin/view/layout/layout_templ.go index da88fb5dc..b1edabada 100644 --- a/weed/admin/view/layout/layout_templ.go +++ b/weed/admin/view/layout/layout_templ.go @@ -381,7 +381,7 @@ func Layout(view ViewContext, content templ.Component) templ.Component { }) } -func LoginForm(title string, errorMessage string, csrfToken string) templ.Component { +func LoginForm(title string, errorMessage string, csrfToken string, localAuthEnabled bool, oidcAuthEnabled bool) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -451,20 +451,44 @@ func LoginForm(title string, errorMessage string, csrfToken string) templ.Compon return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(csrfToken) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/layout/layout.templ`, Line: 393, Col: 84} + if localAuthEnabled && oidcAuthEnabled { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "
or
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err + if oidcAuthEnabled { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "Sign in with OIDC ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if !localAuthEnabled && !oidcAuthEnabled { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "
No sign-in method is configured.
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "\">
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }