2 Commits

Author SHA1 Message Date
ef28805042 Fix template type error on SSO clients page
{{if not .Clients}} fails when .Clients is a non-nil empty slice
because Go templates expect a bool operand for 'not'. Use
{{if eq (len .Clients) 0}} instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 08:09:01 -07:00
33e0f9b8bd Fix SSO clients page template wrapper
Page templates must define a named block that invokes {{template "base"}}
(e.g. {{define "sso_clients"}}{{template "base" .}}{{end}}). Without this,
ExecuteTemplate cannot find the named template and returns an error.

Also add logging to the SSO clients handler for easier diagnosis.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 07:59:06 -07:00
2 changed files with 4 additions and 1 deletions

View File

@@ -12,12 +12,14 @@ import (
func (u *UIServer) handleSSOClientsPage(w http.ResponseWriter, r *http.Request) { func (u *UIServer) handleSSOClientsPage(w http.ResponseWriter, r *http.Request) {
csrfToken, err := u.setCSRFCookies(w) csrfToken, err := u.setCSRFCookies(w)
if err != nil { if err != nil {
u.logger.Error("sso-clients: set CSRF cookies", "error", err)
http.Error(w, "internal error", http.StatusInternalServerError) http.Error(w, "internal error", http.StatusInternalServerError)
return return
} }
clients, err := u.db.ListSSOClients() clients, err := u.db.ListSSOClients()
if err != nil { if err != nil {
u.logger.Error("sso-clients: list clients", "error", err)
u.renderError(w, r, http.StatusInternalServerError, "failed to load SSO clients") u.renderError(w, r, http.StatusInternalServerError, "failed to load SSO clients")
return return
} }

View File

@@ -1,3 +1,4 @@
{{define "sso_clients"}}{{template "base" .}}{{end}}
{{define "title"}} - SSO Clients{{end}} {{define "title"}} - SSO Clients{{end}}
{{define "content"}} {{define "content"}}
<div class="page-header d-flex justify-between align-center"> <div class="page-header d-flex justify-between align-center">
@@ -48,6 +49,6 @@
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
{{if not .Clients}}<p class="text-muted" style="text-align:center;padding:2rem">No SSO clients registered.</p>{{end}} {{if eq (len .Clients) 0}}<p class="text-muted" style="text-align:center;padding:2rem">No SSO clients registered.</p>{{end}}
</div> </div>
{{end}} {{end}}