Improve usability of the user registration
This commit is contained in:
parent
0c2e35bb80
commit
dffd67a9fe
3 changed files with 15 additions and 4 deletions
|
@ -39,13 +39,15 @@ func createUserHandler(h handler) {
|
|||
confirmPass := h.r.FormValue("confirmPass")
|
||||
if pass != confirmPass {
|
||||
h.sess.Notify("Registration error!", "Passwords don't match", "error")
|
||||
} else if pass == "" {
|
||||
h.sess.Notify("Registration error!", "The password can't be empty", "error")
|
||||
} else {
|
||||
user := h.r.FormValue("user")
|
||||
err := h.db.AddUser(user, pass)
|
||||
if err == nil {
|
||||
h.sess.Notify("Account created!", "Welcome "+user+". Now you can login", "success")
|
||||
} else {
|
||||
h.sess.Notify("Registration error!", "There was some database problem, if it keeps happening please inform me", "error")
|
||||
h.sess.Notify("Registration error!", err.Error(), "error")
|
||||
}
|
||||
}
|
||||
h.sess.Save(h.w, h.r)
|
||||
|
|
Reference in a new issue