CHANGE: user login style

This commit is contained in:
2025-02-21 20:44:35 +01:00
parent f6e77bda66
commit 3be2a47c56
8 changed files with 122 additions and 30 deletions

View File

@@ -43,14 +43,19 @@ func parseTimestamp(r *http.Request , get_key string, fallback string) (time.Tim
// Returns bookings from DB with similar card uid -> checks for card uid in http query params
func getBookings(w http.ResponseWriter, r *http.Request) {
// if(!Session.Exists(r.Context(), "user")){
// log.Println("No user in session storage!")
// http.Error(w, "Not logged in!", http.StatusForbidden)
// return
// }
var user models.User
var err error
if(helper.GetEnv("GO_ENV", "production") == "debug"){
user, err = (*models.User).GetByPersonalNummer(nil, 123)
}else{
if(!Session.Exists(r.Context(), "user")){
log.Println("No user in session storage!")
http.Error(w, "Not logged in!", http.StatusForbidden)
return
}
// user, err := (*models.User).GetByPersonalNummer(nil, Session.GetInt(r.Context(), "user"))
user, err := (*models.User).GetByPersonalNummer(nil, 123)
user, err = (*models.User).GetByPersonalNummer(nil, Session.GetInt(r.Context(), "user"))
}
if(err != nil){
log.Println("No user found with the given personal number!")
http.Error(w, "No user found", http.StatusNotFound)