Fixed some bugs with the validation of the end of match requests.

Forgot to change the false of the Authorize() method.

Fixed comparison of Match creator and user that send teh request.
To compare objects don't use ===, use == instead.
This commit is contained in:
Vari
2024-03-06 18:22:22 +01:00
parent 48225057f8
commit a5823b3e0e
4 changed files with 10 additions and 8 deletions

View File

@@ -114,8 +114,8 @@ public function endOfMatch(EndOfMatchRequest $request)
$game = Game::find($request->matchId);
$user = Auth::user();
if($game->creator !== $user)
throw new AuthorizationException('you are not the creator of the match.');
if($game->creator != $user)
return response('you are not the creator of the match.', 403);
$game->status = MatchStatus::Killed;
$game->save();
@@ -131,7 +131,7 @@ public function playerEndOfMatch(PlayerEndOfMatchRequest $request)
if($game === null)
return response('Match not found.', 404);
if ($game->creator !== $user)
if ($game->creator != $user)
throw new AuthorizationException('User is not host of given match');
$user = User::find($request->playerId);