Mercurial > gemma
diff pkg/controllers/user.go @ 425:c49f4c1808b1
Simplified user validation with new UserName type.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 16 Aug 2018 17:31:25 +0200 |
parents | c70ddc6eb168 |
children | fc37e7072022 |
line wrap: on
line diff
--- a/pkg/controllers/user.go Thu Aug 16 15:35:47 2018 +0200 +++ b/pkg/controllers/user.go Thu Aug 16 17:31:25 2018 +0200 @@ -57,8 +57,8 @@ ) (jr JSONResult, err error) { user := mux.Vars(req)["user"] - if user == "" { - err = JSONError{http.StatusBadRequest, "error: user empty"} + if !UserName(user).isValid() { + err = JSONError{http.StatusBadRequest, "error: user invalid"} return } @@ -95,7 +95,7 @@ ) (jr JSONResult, err error) { user := UserName(mux.Vars(req)["user"]) - if user == "" || !user.isValid() { + if !user.isValid() { err = JSONError{http.StatusBadRequest, "error: user invalid"} return } @@ -254,7 +254,7 @@ ) (jr JSONResult, err error) { user := UserName(mux.Vars(req)["user"]) - if user == "" || !user.isValid() { + if !user.isValid() { err = JSONError{http.StatusBadRequest, "error: user invalid"} return }