Hide user settings if login is disabled (#356)
This commit is contained in:
		
							parent
							
								
									ac99317ba3
								
							
						
					
					
						commit
						2785378a0f
					
				
							
								
								
									
										3
									
								
								main.go
								
								
								
								
							
							
						
						
									
										3
									
								
								main.go
								
								
								
								
							|  | @ -128,10 +128,11 @@ func main() { | ||||||
| 		panic(err) | 		panic(err) | ||||||
| 	} | 	} | ||||||
| 	// set app extra data
 | 	// set app extra data
 | ||||||
| 	extraData := make(map[string]string) | 	extraData := make(map[string]interface{}) | ||||||
| 	extraData["appVersion"] = appVersion | 	extraData["appVersion"] = appVersion | ||||||
| 	extraData["gitCommit"] = gitCommit | 	extraData["gitCommit"] = gitCommit | ||||||
| 	extraData["basePath"] = util.BasePath | 	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.
 | 	// 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")
 | 	// "base.html" instead of "templates/base.html")
 | ||||||
|  |  | ||||||
|  | @ -19,7 +19,7 @@ import ( | ||||||
| // TemplateRegistry is a custom html/template renderer for Echo framework
 | // TemplateRegistry is a custom html/template renderer for Echo framework
 | ||||||
| type TemplateRegistry struct { | type TemplateRegistry struct { | ||||||
| 	templates map[string]*template.Template | 	templates map[string]*template.Template | ||||||
| 	extraData map[string]string | 	extraData map[string]interface{} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Render e.Renderer interface
 | // Render e.Renderer interface
 | ||||||
|  | @ -48,7 +48,7 @@ func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // New function
 | // 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 := echo.New() | ||||||
| 	e.Use(session.Middleware(sessions.NewCookieStore(secret))) | 	e.Use(session.Middleware(sessions.NewCookieStore(secret))) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -145,6 +145,7 @@ | ||||||
|                                 </p> |                                 </p> | ||||||
|                             </a> |                             </a> | ||||||
|                         </li> |                         </li> | ||||||
|  |                         {{if not .loginDisabled}} | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a href="{{.basePath}}/users-settings" class="nav-link {{if eq .baseData.Active "users-settings" }}active{{end}}"> |                             <a href="{{.basePath}}/users-settings" class="nav-link {{if eq .baseData.Active "users-settings" }}active{{end}}"> | ||||||
|                             <i class="nav-icon fas fa-cog"></i> |                             <i class="nav-icon fas fa-cog"></i> | ||||||
|  | @ -154,6 +155,7 @@ | ||||||
|                             </a> |                             </a> | ||||||
|                         </li> |                         </li> | ||||||
|                         {{end}} |                         {{end}} | ||||||
|  |                         {{end}} | ||||||
| 
 | 
 | ||||||
|                         <li class="nav-header">UTILITIES</li> |                         <li class="nav-header">UTILITIES</li> | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue