CHANGE: sorted .templ files + added css classes + added nav header
This commit is contained in:
@@ -34,7 +34,7 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func UserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if !Session.Exists(r.Context(), "user") {
|
||||
http.Redirect(w, r, "/user/login", http.StatusTemporaryRedirect)
|
||||
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||
}
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
@@ -50,7 +50,7 @@ func UserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func showLoginForm(w http.ResponseWriter, r *http.Request, failed bool) {
|
||||
templates.LoginForm(failed).Render(r.Context(), w)
|
||||
templates.LoginPage(failed).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func loginUser(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -86,8 +86,10 @@ func loginUser(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/time", http.StatusSeeOther) //with this browser always uses GET
|
||||
} else {
|
||||
showLoginForm(w, r, true)
|
||||
return
|
||||
}
|
||||
showLoginForm(w, r, false)
|
||||
return
|
||||
}
|
||||
|
||||
// change user password and store salted hash in db
|
||||
@@ -102,6 +104,7 @@ func changePassword(w http.ResponseWriter, r *http.Request) {
|
||||
newPassword := r.FormValue("new_password")
|
||||
if password == "" || newPassword == "" || newPassword != r.FormValue("new_password_repeat") {
|
||||
showPWForm(w, r, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
user, err := (*models.User).GetByPersonalNummer(nil, Session.GetInt(r.Context(), "user"))
|
||||
if err != nil {
|
||||
@@ -120,5 +123,6 @@ func changePassword(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func showPWForm(w http.ResponseWriter, r *http.Request, status int) {
|
||||
templates.UserForm(status).Render(r.Context(), w)
|
||||
templates.UserPage(status).Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user