Add the trim as well for the user creation

This commit is contained in:
Las Zenow 2018-04-26 11:13:08 +00:00
parent f6cf82fcb3
commit 645c4ce217

View file

@ -1,6 +1,8 @@
package trantor package trantor
import ( import (
"strings"
log "github.com/cihub/seelog" log "github.com/cihub/seelog"
"gitlab.com/trantor/trantor/lib/database" "gitlab.com/trantor/trantor/lib/database"
@ -42,7 +44,7 @@ func createUserHandler(h handler) {
} else if pass == "" { } else if pass == "" {
h.sess.Notify("Registration error!", "The password can't be empty", "error") h.sess.Notify("Registration error!", "The password can't be empty", "error")
} else { } else {
user := h.r.FormValue("user") user := strings.TrimSpace(h.r.FormValue("user"))
err := h.db.AddUser(user, pass) err := h.db.AddUser(user, pass)
if err == nil { if err == nil {
h.sess.Notify("Account created!", "Welcome "+user+". Now you can login", "success") h.sess.Notify("Account created!", "Welcome "+user+". Now you can login", "success")