diff --git a/app/routes.go b/app/routes.go index 035cfb2..2940397 100644 --- a/app/routes.go +++ b/app/routes.go @@ -56,8 +56,11 @@ func (a *App) SetupRoutes() error { base.HEAD("/", handlers.Index()) base.GET("/signin", handlers.Signin(), compress) base.POST("/signin", handlers.SigninPost(a.db)) - base.GET("/signup", handlers.Signup(), compress) - base.POST("/signup", handlers.SignupPost(a.db)) + + if a.setting.RegistrationAllowed { + base.GET("/signup", handlers.Signup(), compress) + base.POST("/signup", handlers.SignupPost(a.db)) + } base.GET("/home", handlers.Home(a.db)) diff --git a/app/settings/settings.go b/app/settings/settings.go index cc0c610..b9e7928 100644 --- a/app/settings/settings.go +++ b/app/settings/settings.go @@ -39,6 +39,7 @@ type Settings struct { dbConnstring string dbType string dbIsSetUp bool + RegistrationAllowed bool } const ( @@ -160,6 +161,10 @@ func (s *Settings) Consolidate(conf *config.Config, host *string, port *int, dev } } + if conf.Registration.Allowed { + s.RegistrationAllowed = true + } + s.SetVersion(version) } diff --git a/handlers/config.go b/handlers/config.go index 30554d5..c45ba38 100644 --- a/handlers/config.go +++ b/handlers/config.go @@ -11,13 +11,14 @@ import ( ) var ( - setting *settings.Settings - appver string - appName = "pcmt" - appIsDevel bool - slogger *slogging.Slogger - log slogging.Slogger - dbclient *ent.Client + setting *settings.Settings + appver string + appName = "pcmt" + appIsDevel bool + slogger *slogging.Slogger + log slogging.Slogger + dbclient *ent.Client + registrationAllowed bool ) func SetDBClient(client *ent.Client) { @@ -36,4 +37,5 @@ func InitHandlers(s *settings.Settings) { appName = setting.AppName() appver = setting.Version() appIsDevel = setting.IsDevel() + registrationAllowed = setting.RegistrationAllowed } diff --git a/handlers/page.go b/handlers/page.go index f6d869c..bffca83 100644 --- a/handlers/page.go +++ b/handlers/page.go @@ -21,10 +21,15 @@ type page struct { } func newPage() *page { + data := make(map[string]any, 0) + + data["RegistrationAllowed"] = registrationAllowed + p := &page{ AppName: appName, AppVer: appver, DevelMode: appIsDevel, + Data: data, } return p diff --git a/templates/navbar.tmpl b/templates/navbar.tmpl index 93429b2..ef551de 100644 --- a/templates/navbar.tmpl +++ b/templates/navbar.tmpl @@ -46,6 +46,7 @@