mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 22:52:09 +00:00
do not need login
This commit is contained in:
@@ -18,7 +18,7 @@ class ShowEmbeddedRoomRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
@@ -67,17 +67,28 @@ class ShowEmbeddedRoomRequest extends FormRequest
|
||||
return;
|
||||
}
|
||||
|
||||
if ($room === null || $this->user() === null) {
|
||||
if ($room === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sessionPlayerId = $this->session()->get("room_players.{$room->id}");
|
||||
$existingPlayer = is_numeric($sessionPlayerId)
|
||||
? $room->players()->find((int) $sessionPlayerId)
|
||||
: null;
|
||||
|
||||
if ($existingPlayer === null && $this->user() !== null) {
|
||||
$existingPlayer = $room->players()
|
||||
->where('user_id', $this->user()->id)
|
||||
->first();
|
||||
}
|
||||
|
||||
$nameIsTaken = Player::query()
|
||||
->where('room_id', $room->id)
|
||||
->where('name', $this->input('player_name'))
|
||||
->where(function ($query): void {
|
||||
$query->whereNull('user_id')
|
||||
->orWhere('user_id', '!=', $this->user()->id);
|
||||
})
|
||||
->when(
|
||||
$existingPlayer !== null,
|
||||
fn ($query) => $query->whereKeyNot($existingPlayer->id),
|
||||
)
|
||||
->exists();
|
||||
|
||||
if ($nameIsTaken) {
|
||||
|
||||
Reference in New Issue
Block a user