added userLogout fixes #15, #10

This commit is contained in:
2025-05-01 19:42:33 +02:00
parent 35ec575a05
commit 9a88397bb2
11 changed files with 151 additions and 89 deletions

View File

@@ -47,8 +47,9 @@ func (b *Booking) FromUrlParams(params url.Values) Booking {
return booking
}
func (b Booking) Verify() bool {
if b.CardUID == "" || b.GeraetID == 0 || b.CheckInOut == 0 {
func (b *Booking) Verify() bool {
//check for overlapping time + arbeitszeit verstoß
if b.CardUID == "" { //|| b.GeraetID == 0 || b.CheckInOut == 0 {
return false
}
return true
@@ -71,7 +72,7 @@ func (b *Booking) Insert() error {
func (b *Booking) InsertTimestamp() error {
if b.Timestamp.IsZero() {
b.Timestamp = time.Now()
return b.Insert()
}
stmt, err := DB.Prepare((`INSERT INTO anwesenheit (card_uid, geraet_id, check_in_out, timestamp) VALUES ($1, $2, $3, $4) RETURNING counter_id`))
if err != nil {
@@ -251,7 +252,9 @@ func (b *Booking) UpdateTime(newTime time.Time) {
if b.CheckInOut == 254 {
newBooking.CheckInOut = 4
}
log.Println("Updating")
b.Update(newBooking)
b.Verify()
b.Save()
}