1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: add config option to disable user registrations (resolve #113)

This commit is contained in:
Ferdinand Mütsch
2021-02-06 10:59:12 +01:00
parent 22260ceb0d
commit d728426b45
5 changed files with 11 additions and 2 deletions

View File

@@ -121,6 +121,12 @@ func (h *LoginHandler) PostSignup(w http.ResponseWriter, r *http.Request) {
loadTemplates()
}
if !h.config.IsDev() && !h.config.Security.AllowSignup {
w.WriteHeader(http.StatusForbidden)
templates[conf.SignupTemplate].Execute(w, h.buildViewModel(r).WithError("registration is disabled on this server"))
return
}
if cookie, err := r.Cookie(models.AuthCookieKey); err == nil && cookie.Value != "" {
http.Redirect(w, r, fmt.Sprintf("%s/summary", h.config.Server.BasePath), http.StatusFound)
return