mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 18:32:09 +00:00
Handle authenticated room instance takeover
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Http\Resources\RoomResource;
|
||||
use App\Models\Room;
|
||||
use App\Services\Rooms\RoomPageService;
|
||||
use App\Services\Rooms\RoomParticipationService;
|
||||
use App\Services\Rooms\RoomPlayerInstanceService;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
@@ -16,6 +17,7 @@ class EmbeddedRoomController extends Controller
|
||||
public function __construct(
|
||||
private readonly RoomParticipationService $roomParticipation,
|
||||
private readonly RoomPageService $roomPage,
|
||||
private readonly RoomPlayerInstanceService $playerInstances,
|
||||
) {}
|
||||
|
||||
public function __invoke(ShowEmbeddedRoomRequest $request): Response
|
||||
@@ -33,6 +35,11 @@ class EmbeddedRoomController extends Controller
|
||||
$validated['player_name'],
|
||||
$request->session()->get("room_players.{$room->id}"),
|
||||
);
|
||||
$player = $this->roomParticipation->activateInstance(
|
||||
$room,
|
||||
$player,
|
||||
$this->playerInstances->for($request),
|
||||
);
|
||||
|
||||
$request->session()->put("room_players.{$room->id}", $player->id);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Player;
|
||||
use App\Models\Room;
|
||||
use App\Services\Rooms\RoomCreationService;
|
||||
use App\Services\Rooms\RoomPageService;
|
||||
use App\Services\Rooms\RoomPlayerInstanceService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
@@ -20,6 +21,7 @@ class RoomController extends Controller
|
||||
public function __construct(
|
||||
private readonly RoomCreationService $roomCreation,
|
||||
private readonly RoomPageService $roomPage,
|
||||
private readonly RoomPlayerInstanceService $playerInstances,
|
||||
) {}
|
||||
|
||||
public function create(Request $request): Response
|
||||
@@ -40,6 +42,9 @@ class RoomController extends Controller
|
||||
$validated,
|
||||
$request->user(),
|
||||
);
|
||||
$player->update([
|
||||
'active_instance_id' => $this->playerInstances->for($request),
|
||||
]);
|
||||
|
||||
$request->session()->put(
|
||||
"room_players.{$room->id}",
|
||||
|
||||
@@ -4,12 +4,14 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\JoinRoomRequest;
|
||||
use App\Services\Rooms\RoomParticipationService;
|
||||
use App\Services\Rooms\RoomPlayerInstanceService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RoomPlayerController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly RoomParticipationService $roomParticipation,
|
||||
private readonly RoomPlayerInstanceService $playerInstances,
|
||||
) {}
|
||||
|
||||
public function join(JoinRoomRequest $request): RedirectResponse
|
||||
@@ -23,6 +25,11 @@ class RoomPlayerController extends Controller
|
||||
$request->user(),
|
||||
is_array($sessionPlayerIds) ? $sessionPlayerIds : [],
|
||||
);
|
||||
$player = $this->roomParticipation->activateInstance(
|
||||
$room,
|
||||
$player,
|
||||
$this->playerInstances->for($request),
|
||||
);
|
||||
|
||||
$request->session()->put(
|
||||
"room_players.{$room->id}",
|
||||
|
||||
Reference in New Issue
Block a user