Match trainer and secret ID on update for data integrity

This commit is contained in:
Flashfyre committed 2024-04-25 09:56:56 -04:00
1 parent 849bc601f0
commit 2f8c2d3f07
3 files changed
+56 -1

No files matched your search

+18
View File
@@ -175,6 +175,24 @@ func FetchAccountKeySaltFromUsername(username string) ([]byte, []byte, error) {
return key, salt, nil
}
func FetchTrainerIds(uuid []byte) (trainerId int, secretId int, err error) {
err = handle.QueryRow("SELECT trainerId, secretId FROM accounts WHERE uuid = ?", uuid).Scan(&trainerId, &secretId)
if err != nil {
return 0, 0, err
}
return trainerId, secretId, nil
}
func UpdateTrainerIds(trainerId int, secretId int, uuid []byte) error {
_, err := handle.Exec("UPDATE accounts SET trainerId = ?, secretId = ? WHERE uuid = ?", trainerId, secretId, uuid)
if err != nil {
return err
}
return nil
}
func IsActiveSession(token []byte) (bool, error) {
var active int
err := handle.QueryRow("SELECT `active` FROM sessions WHERE token = ?", token).Scan(&active)