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 = window.app || {}
|
||||||
window.app.settings = {{ .settings }};
|
window.app.settings = {{ .settings }};
|
||||||
window.app.authenticated = {{ .authenticated }};
|
window.app.authenticated = {{ .authenticated }};
|
||||||
|
window.app.requiresAuth = {{ .requiresAuth }};
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body class="theme-{{ .settings.theme_name }}">
|
<body class="theme-{{ .settings.theme_name }}">
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export default {
|
|||||||
},
|
},
|
||||||
'refreshRate': s.refresh_rate,
|
'refreshRate': s.refresh_rate,
|
||||||
'authenticated': app.authenticated,
|
'authenticated': app.authenticated,
|
||||||
|
'requiresAuth': app.requiresAuth,
|
||||||
'feed_errors': {},
|
'feed_errors': {},
|
||||||
|
|
||||||
'refreshRateOptions': [
|
'refreshRateOptions': [
|
||||||
|
|||||||
@@ -117,8 +117,8 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-divider" v-if="authenticated"></div>
|
<div class="dropdown-divider" v-if="requiresAuth"></div>
|
||||||
<button class="dropdown-item" v-if="authenticated" @click="logout()">
|
<button class="dropdown-item" v-if="requiresAuth" @click="logout()">
|
||||||
<v-icon class="mr-1" name="log-out" />
|
<v-icon class="mr-1" name="log-out" />
|
||||||
{{ $t('log_out') }}
|
{{ $t('log_out') }}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -67,16 +67,18 @@ func (s *Server) handler() http.Handler {
|
|||||||
|
|
||||||
func (s *Server) handleIndex(c *router.Context) {
|
func (s *Server) handleIndex(c *router.Context) {
|
||||||
isAuthenticated := false
|
isAuthenticated := false
|
||||||
|
requiresAuth := false
|
||||||
if s.Username == "" && s.Password == "" {
|
if s.Username == "" && s.Password == "" {
|
||||||
isAuthenticated = true
|
isAuthenticated = true
|
||||||
} else {
|
} else {
|
||||||
|
requiresAuth = true
|
||||||
isAuthenticated = auth.IsAuthenticated(c.Req, s.Username, s.Password)
|
isAuthenticated = auth.IsAuthenticated(c.Req, s.Username, s.Password)
|
||||||
}
|
}
|
||||||
|
|
||||||
settings := s.db.GetSettings()
|
settings := s.db.GetSettings()
|
||||||
if !isAuthenticated {
|
if !isAuthenticated {
|
||||||
settings = model.Settings{
|
settings = model.Settings{
|
||||||
Language: settings.Language,
|
Language: settings.Language,
|
||||||
ThemeName: settings.ThemeName,
|
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{
|
c.HTML(http.StatusOK, assets.Templates().Lookup("index.html"), map[string]any{
|
||||||
"settings": settings.Map(),
|
"settings": settings.Map(),
|
||||||
"authenticated": isAuthenticated,
|
"authenticated": isAuthenticated,
|
||||||
|
"requiresAuth": requiresAuth,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user