Skip to content

Commit

Permalink
Hide user settings if login is disabled (#356) (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream authored May 24, 2023
1 parent cfbdae7 commit ec75728
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ func main() {
panic(err)
}
// set app extra data
extraData := make(map[string]string)
extraData := make(map[string]interface{})
extraData["appVersion"] = appVersion
extraData["gitCommit"] = gitCommit
extraData["basePath"] = util.BasePath
extraData["loginDisabled"] = flagDisableLogin

// strip the "templates/" prefix from the embedded directory so files can be read by their direct name (e.g.
// "base.html" instead of "templates/base.html")
Expand Down
4 changes: 2 additions & 2 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// TemplateRegistry is a custom html/template renderer for Echo framework
type TemplateRegistry struct {
templates map[string]*template.Template
extraData map[string]string
extraData map[string]interface{}
}

// Render e.Renderer interface
Expand Down Expand Up @@ -48,7 +48,7 @@ func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c
}

// New function
func New(tmplDir fs.FS, extraData map[string]string, secret []byte) *echo.Echo {
func New(tmplDir fs.FS, extraData map[string]interface{}, secret []byte) *echo.Echo {
e := echo.New()
e.Use(session.Middleware(sessions.NewCookieStore(secret)))

Expand Down
2 changes: 2 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
</p>
</a>
</li>
{{if not .loginDisabled}}
<li class="nav-item">
<a href="{{.basePath}}/users-settings" class="nav-link {{if eq .baseData.Active "users-settings" }}active{{end}}">
<i class="nav-icon fas fa-cog"></i>
Expand All @@ -154,6 +155,7 @@
</a>
</li>
{{end}}
{{end}}

<li class="nav-header">UTILITIES</li>
<li class="nav-item">
Expand Down

0 comments on commit ec75728

Please sign in to comment.