From 476e667572baccfc59429cd7befea2d401bc07fb Mon Sep 17 00:00:00 2001 From: maru Date: Fri, 24 May 2024 01:47:36 -0400 Subject: [PATCH] More cleanup --- db/account.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/db/account.go b/db/account.go index 0d2cd8a..9ac1ec2 100644 --- a/db/account.go +++ b/db/account.go @@ -219,21 +219,23 @@ func UpdateTrainerIds(trainerId, secretId int, uuid []byte) error { return nil } -func IsActiveSession(uuid []byte, clientSessionId string) (bool, error) { - var storedId string - err := handle.QueryRow("SELECT clientSessionId FROM activeClientSessions WHERE uuid = ?", uuid).Scan(&storedId) +func IsActiveSession(uuid []byte, sessionId string) (bool, error) { + var id string + err := handle.QueryRow("SELECT clientSessionId FROM activeClientSessions WHERE uuid = ?", uuid).Scan(&id) if err != nil { if errors.Is(err, sql.ErrNoRows) { - err = UpdateActiveSession(uuid, clientSessionId) + err = UpdateActiveSession(uuid, sessionId) if err != nil { return false, err } + return true, nil } + return false, err } - return storedId == "" || storedId == clientSessionId, nil + return id == "" || id == sessionId, nil } func UpdateActiveSession(uuid []byte, clientSessionId string) error {