mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 19:12:10 +00:00
feat: some fixes to the ui, imlemented user and guest user, ans used the dahboard
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
||||
use App\Models\Room;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class EnsureRoomParticipant
|
||||
@@ -23,23 +24,48 @@ class EnsureRoomParticipant
|
||||
}
|
||||
|
||||
$sessionKey = "room_players.{$room->id}";
|
||||
$playerId = $request->session()->get($sessionKey);
|
||||
|
||||
if (! $playerId) {
|
||||
if ($room->trashed()) {
|
||||
$request->session()->forget($sessionKey);
|
||||
Inertia::flash('toast', [
|
||||
'type' => 'info',
|
||||
'message' => 'Dieser Raum wurde gelöscht.',
|
||||
]);
|
||||
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
if ($room->isClosed()) {
|
||||
return to_route('room.join', [
|
||||
'join_code' => $room->join_code,
|
||||
])->withErrors([
|
||||
'join_code' => 'Du musst diesen Raum erst beitreten.',
|
||||
'join_code' => 'Dieser Raum ist geschlossen.',
|
||||
]);
|
||||
}
|
||||
|
||||
$player = $room->players()->find($playerId);
|
||||
$playerId = $request->session()->get($sessionKey);
|
||||
|
||||
if (! $player) {
|
||||
$player = $playerId ? $room->players()->find($playerId) : null;
|
||||
|
||||
if ($player === null && $playerId) {
|
||||
$request->session()->forget($sessionKey);
|
||||
}
|
||||
|
||||
if ($player === null && $request->user() !== null) {
|
||||
$player = $room->players()
|
||||
->where('user_id', $request->user()->id)
|
||||
->first();
|
||||
|
||||
if ($player !== null) {
|
||||
$request->session()->put($sessionKey, $player->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($player === null) {
|
||||
return to_route('room.join', [
|
||||
'join_code' => $room->join_code,
|
||||
])->withErrors([
|
||||
'join_code' => 'Du musst diesem Raum erst beitreten.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user