diff --git a/dist/app/Http/Controllers/Api/Matchmaking/MatchmakingController.php b/dist/app/Http/Controllers/Api/Matchmaking/MatchmakingController.php index 7899043..573664d 100644 --- a/dist/app/Http/Controllers/Api/Matchmaking/MatchmakingController.php +++ b/dist/app/Http/Controllers/Api/Matchmaking/MatchmakingController.php @@ -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); diff --git a/dist/app/Http/Controllers/Api/Player/ChallengeController.php b/dist/app/Http/Controllers/Api/Player/ChallengeController.php index c32d067..7d44e38 100644 --- a/dist/app/Http/Controllers/Api/Player/ChallengeController.php +++ b/dist/app/Http/Controllers/Api/Player/ChallengeController.php @@ -76,7 +76,7 @@ public function executeChallengeProgressionBatch(ExecuteChallengeProgressionBatc // Only allow the saving of challenge progress if the request comes from the same user as from the // game the request is coming from. - if($user !== $foundGame->creator) + if($user != $foundGame->creator) throw new AuthorizationException('Not allowed to save progress'); $progressUser = User::find($request->userId); diff --git a/dist/app/Http/Requests/Api/Matchmaking/EndOfMatchRequest.php b/dist/app/Http/Requests/Api/Matchmaking/EndOfMatchRequest.php index 385c1e5..000843a 100644 --- a/dist/app/Http/Requests/Api/Matchmaking/EndOfMatchRequest.php +++ b/dist/app/Http/Requests/Api/Matchmaking/EndOfMatchRequest.php @@ -3,6 +3,7 @@ namespace App\Http\Requests\Api\Matchmaking; use App\Enums\Game\Faction; +use Auth; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; @@ -19,7 +20,7 @@ class EndOfMatchRequest extends FormRequest */ public function authorize(): bool { - return false; + return Auth::check(); } /** @@ -39,7 +40,7 @@ public function rules(): array protected function passedValidation() { $this->players = $this->input('data.players'); - $this->dominantFaction = $this->input('data.dominantFaction'); - $this->matchId = $this->input('matchId'); + $this->dominantFaction = Faction::tryFrom($this->input('data.dominantFaction')); + $this->matchId = $this->input('data.matchId'); } } diff --git a/dist/app/Http/Requests/Api/Matchmaking/PlayerEndOfMatchRequest.php b/dist/app/Http/Requests/Api/Matchmaking/PlayerEndOfMatchRequest.php index 5e311fa..b30ba80 100644 --- a/dist/app/Http/Requests/Api/Matchmaking/PlayerEndOfMatchRequest.php +++ b/dist/app/Http/Requests/Api/Matchmaking/PlayerEndOfMatchRequest.php @@ -5,6 +5,7 @@ use App\Enums\Game\Faction; use App\Enums\Game\ItemGroupType; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Support\Facades\Auth; use Illuminate\Validation\Rule; class PlayerEndOfMatchRequest extends FormRequest @@ -38,7 +39,7 @@ class PlayerEndOfMatchRequest extends FormRequest */ public function authorize(): bool { - return false; + return Auth::check(); } /**