diff --git a/cmd/ui/ui.go b/cmd/ui/handlers.go similarity index 94% rename from cmd/ui/ui.go rename to cmd/ui/handlers.go index eb3ab51..92454e0 100644 --- a/cmd/ui/ui.go +++ b/cmd/ui/handlers.go @@ -61,6 +61,10 @@ func HandleAddUser(db *data.DB) http.HandlerFunc { last := r.PostFormValue("last-name") role := r.PostFormValue("role") + if inputsEmpty(user, pass, pass2, first, last, role) { + log.Println("inputsEmpty") + template.Must(template.ParseFiles("web/templates/add-user.html")).Execute(w, nil) + } _, _, ok := checkUserStrings(user, first, last) if !ok { log.Println("checkUserStrings") diff --git a/cmd/ui/helpers.go b/cmd/ui/helpers.go index b88ffbe..6ea045a 100644 --- a/cmd/ui/helpers.go +++ b/cmd/ui/helpers.go @@ -1,5 +1,14 @@ package ui +func inputsEmpty(user, pass, pass2, first, last, role string) bool { + return len(user) == 0 || + len(pass) == 0 || + len(pass2) == 0 || + len(first) == 0 || + len(last) == 0 || + len(role) == 0 +} + func checkUserStrings(user, first, last string) (string, int, bool) { userLen := 15 nameLen := 50 diff --git a/web/templates/add-user.html b/web/templates/add-user.html index 4341202..4cfacfd 100644 --- a/web/templates/add-user.html +++ b/web/templates/add-user.html @@ -1,19 +1,19 @@ {{define "page-content"}}

Neuer Benutzer

- - - + + + - - + + - + - + - +