check hash before checking if user already has access

This commit is contained in:
RickyRister 2025-08-19 22:21:29 -07:00
parent 88052f1b06
commit a02e89e36b

View file

@ -834,6 +834,11 @@ Response::ResponseCode AbstractServerSocketInterface::cmdReplaySubmitCode(const
const auto &replayName = replayExistsQuery->value(0).toString();
// Check if hash is correct
if (hash != createHashForReplay(gameId.toInt())) {
return Response::RespNameNotFound;
}
// Determine if user already has access to replay
auto *alreadyAccessQuery = sqlInterface->prepareQuery(
"select 1 from {prefix}_replays_access where id_game = :id_game and id_player = :id_player");
@ -846,11 +851,6 @@ Response::ResponseCode AbstractServerSocketInterface::cmdReplaySubmitCode(const
return Response::RespOk;
}
// Check if hash is correct
if (hash != createHashForReplay(gameId.toInt())) {
return Response::RespNameNotFound;
}
// Grant the User access to the replay
auto *grantReplayAccessQuery =
sqlInterface->prepareQuery("insert into {prefix}_replays_access (id_game, id_player, replay_name, do_not_hide) "