From 9918c43527db560076506aee57375749ea9668d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Tr=C3=B6ger?= Date: Thu, 24 Apr 2025 17:48:03 +0200 Subject: [PATCH] fixed autoLogout --- Backend/endpoints/auto_logout.go | 6 ++++-- Backend/models/user.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Backend/endpoints/auto_logout.go b/Backend/endpoints/auto_logout.go index b27f75f..7ff899c 100644 --- a/Backend/endpoints/auto_logout.go +++ b/Backend/endpoints/auto_logout.go @@ -5,6 +5,7 @@ import ( "arbeitszeitmessung/models" "encoding/json" "fmt" + "log" "net/http" ) @@ -29,8 +30,9 @@ func autoLogout(w http.ResponseWriter) { err = user.Logout() if err != nil { fmt.Printf("Error logging out user %v\n", err) - }else { - logged_out_users = append(logged_out_users, user) + } else { + logged_out_users = append(logged_out_users, user) + log.Printf("Automaticaly logged out user %s, %s ", user.Name, user.Vorname) } } diff --git a/Backend/models/user.go b/Backend/models/user.go index e5f5bd0..92a6a21 100644 --- a/Backend/models/user.go +++ b/Backend/models/user.go @@ -68,7 +68,7 @@ func (u *User) GetAll() ([]User, error) { // Returns true if there is a booking 1 for today -> meaning the user is at work // Returns false if there is no booking today or the user is already booked out of the system func (u *User) CheckAnwesenheit() bool { - qStr, err := DB.Prepare((`SELECT check_in_out FROM anwesenheit WHERE card_uid = $1 AND "timestamp" >= now()::date + interval '1h' ORDER BY "timestamp" DESC LIMIT 1;`)) + qStr, err := DB.Prepare((`SELECT check_in_out FROM anwesenheit WHERE card_uid = $1 AND "timestamp"::date = now()::date ORDER BY "timestamp" DESC LIMIT 1;`)) if err != nil { fmt.Printf("Error preparing query statement %v\n", err) return false