Port the web to bootstrap5
So it is responsive in phones.
This commit is contained in:
parent
8af2ad3758
commit
6a3da59c75
40 changed files with 1131 additions and 849 deletions
22
lib/user.go
22
lib/user.go
|
@ -30,7 +30,7 @@ func loginPostHandler(h handler) {
|
|||
h.sess.Notify("Successful login!", "Welcome "+user, "success")
|
||||
} else {
|
||||
log.Warn("User ", user, " bad user or password")
|
||||
h.sess.Notify("Invalid login!", "user or password invalid", "error")
|
||||
h.sess.Notify("Invalid login!", "user or password invalid", "danger")
|
||||
}
|
||||
h.sess.Save(h.w, h.r)
|
||||
http.Redirect(h.w, h.r, h.r.Referer(), http.StatusFound)
|
||||
|
@ -40,16 +40,16 @@ func createUserHandler(h handler) {
|
|||
pass := h.r.FormValue("pass")
|
||||
confirmPass := h.r.FormValue("confirmPass")
|
||||
if pass != confirmPass {
|
||||
h.sess.Notify("Registration error!", "Passwords don't match", "error")
|
||||
h.sess.Notify("Registration error!", "Passwords don't match", "danger")
|
||||
} 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", "danger")
|
||||
} else {
|
||||
user := strings.TrimSpace(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!", err.Error(), "error")
|
||||
h.sess.Notify("Registration error!", err.Error(), "danger")
|
||||
}
|
||||
}
|
||||
h.sess.Save(h.w, h.r)
|
||||
|
@ -91,14 +91,14 @@ func settingsHandler(h handler) {
|
|||
pass2 := h.r.FormValue("password2")
|
||||
switch {
|
||||
case !h.db.ValidPassword(h.sess.User, current_pass):
|
||||
h.sess.Notify("Password error!", "The current password given don't match with the user password. Try again", "error")
|
||||
h.sess.Notify("Password error!", "The current password given don't match with the user password. Try again", "danger")
|
||||
case pass1 != pass2:
|
||||
h.sess.Notify("Passwords don't match!", "The new password and the confirmation password don't match. Try again", "error")
|
||||
h.sess.Notify("Passwords don't match!", "The new password and the confirmation password don't match. Try again", "danger")
|
||||
default:
|
||||
err := h.db.SetPassword(h.sess.User, pass1)
|
||||
if err != nil {
|
||||
log.Warn("Can't update password for user ", h.sess.User, ": ", err)
|
||||
h.sess.Notify("Password error!", "An error has ocurred updating the password in the database. Sorry.", "error")
|
||||
h.sess.Notify("Password error!", "An error has ocurred updating the password in the database. Sorry.", "danger")
|
||||
} else {
|
||||
h.sess.Notify("Password updated!", "Your new password is correctly set.", "success")
|
||||
}
|
||||
|
@ -167,14 +167,14 @@ func userAdminPostHandler(h handler) {
|
|||
if password != "" {
|
||||
err := h.db.SetPassword(username, password)
|
||||
if err != nil {
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "error")
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "danger")
|
||||
} else {
|
||||
h.sess.Notify("Password updated!", "", "success")
|
||||
}
|
||||
} else if role != "" {
|
||||
err := h.db.SetRole(username, role)
|
||||
if err != nil {
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "error")
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "danger")
|
||||
} else {
|
||||
h.sess.Notify("Role updated!", "", "success")
|
||||
}
|
||||
|
@ -194,11 +194,11 @@ func addUserHandler(h handler) {
|
|||
role := h.r.FormValue("role")
|
||||
err := h.db.AddUser(username, password)
|
||||
if err != nil {
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "error")
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "danger")
|
||||
} else {
|
||||
err := h.db.SetRole(username, role)
|
||||
if err != nil {
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "error")
|
||||
h.sess.Notify("An error ocurred!", err.Error(), "danger")
|
||||
} else {
|
||||
h.sess.Notify("User created!", "", "success")
|
||||
}
|
||||
|
|
Reference in a new issue