CHANGE: sorted .templ files + added css classes + added nav header

This commit is contained in:
2025-02-24 10:42:09 +01:00
parent fdd6416ad9
commit a4e0bf82c9
18 changed files with 384 additions and 477 deletions

View File

@@ -83,7 +83,7 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
return
}
ctx := context.WithValue(r.Context(), "user", user)
templates.TimeDashboard(bookings).Render(ctx, w)
templates.TimePage(bookings).Render(ctx, w)
}
func updateBooking(w http.ResponseWriter, r *http.Request) {

View File

@@ -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
}