Match trainer and secret ID on update for data integrity
This commit is contained in:
1 parent
849bc601f0
commit
2f8c2d3f07
3 files changed
+56
-1
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user