mirror of
https://github.com/nkanaev/yarr.git
synced 2026-07-15 11:06:31 +00:00
frontend: show logout button only if user/pass is set
This commit is contained in:
@@ -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 }}">
|
||||
|
||||
@@ -90,6 +90,7 @@ export default {
|
||||
},
|
||||
'refreshRate': s.refresh_rate,
|
||||
'authenticated': app.authenticated,
|
||||
'requiresAuth': app.requiresAuth,
|
||||
'feed_errors': {},
|
||||
|
||||
'refreshRateOptions': [
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user