Admin console: show the signed-in operator's name, not "Administrator"

The user switcher fell back to "Administrator" whenever /admin/api/status
returned no currentUser. Fresh sign-ins already embed the verified Emby
account name in the session cookie, but a session minted before that field
existed (or one that has not been re-issued since) is valid yet anonymous,
so the fallback showed for ever.

handleAdminConsole now treats a valid-but-anonymous admin session as needing
a fresh sign-in for the SPA shell only — a one-time prompt that fills the
name in, since session renewal preserves whatever the cookie already held.
Asset requests are unaffected, so nothing breaks mid-session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011wS9Qz3Fkxeu9KPt26hhhx
This commit is contained in:
ponzischeme89
2026-08-28 23:36:11 +12:00
co-authored by Claude Sonnet 5
parent d5632e844a
commit 0b1d329f7c
3 changed files with 50 additions and 0 deletions
+11
View File
@@ -164,6 +164,17 @@ func (s *Server) validAdminSession(r *http.Request) bool {
return ok
}
// adminSessionNamed reports whether the request's admin session carries the verified Emby
// account name. Every session minted since the identity was added to the cookie has one;
// a session predating it is valid but anonymous, which is what makes the console's user
// switcher fall back to "Administrator" instead of showing who is signed in. The console
// document handler treats an anonymous session as needing a fresh sign-in so the name is
// picked up — a one-time prompt, since renewal preserves whatever the cookie already held.
func (s *Server) adminSessionNamed(r *http.Request) bool {
_, username, ok := s.browserSession(r, adminSessionPurpose)
return ok && username != ""
}
// renewAdminSession slides a valid session's expiry forward. The TTL was absolute and
// nothing extended it, so an operator working the admin console was signed out from under
// themselves and the page's poll became a permanent "invalid admin