frontend: show logout button only if user/pass is set

This commit is contained in:
nkanaev
2026-07-06 23:59:00 +01:00
parent 499960a96f
commit a96bd00be5
4 changed files with 8 additions and 3 deletions

View File

@@ -13,6 +13,7 @@
window.app = window.app || {}
window.app.settings = {{ .settings }};
window.app.authenticated = {{ .authenticated }};
window.app.requiresAuth = {{ .requiresAuth }};
</script>
</head>
<body class="theme-{{ .settings.theme_name }}">

View File

@@ -90,6 +90,7 @@ export default {
},
'refreshRate': s.refresh_rate,
'authenticated': app.authenticated,
'requiresAuth': app.requiresAuth,
'feed_errors': {},
'refreshRateOptions': [

View File

@@ -117,8 +117,8 @@
</button>
</div>
</div>
<div class="dropdown-divider" v-if="authenticated"></div>
<button class="dropdown-item" v-if="authenticated" @click="logout()">
<div class="dropdown-divider" v-if="requiresAuth"></div>
<button class="dropdown-item" v-if="requiresAuth" @click="logout()">
<v-icon class="mr-1" name="log-out" />
{{ $t('log_out') }}
</button>

View File

@@ -67,16 +67,18 @@ func (s *Server) handler() http.Handler {
func (s *Server) handleIndex(c *router.Context) {
isAuthenticated := false
requiresAuth := false
if s.Username == "" && s.Password == "" {
isAuthenticated = true
} else {
requiresAuth = true
isAuthenticated = auth.IsAuthenticated(c.Req, s.Username, s.Password)
}
settings := s.db.GetSettings()
if !isAuthenticated {
settings = model.Settings{
Language: settings.Language,
Language: settings.Language,
ThemeName: settings.ThemeName,
}
}
@@ -84,6 +86,7 @@ func (s *Server) handleIndex(c *router.Context) {
c.HTML(http.StatusOK, assets.Templates().Lookup("index.html"), map[string]any{
"settings": settings.Map(),
"authenticated": isAuthenticated,
"requiresAuth": requiresAuth,
})
}