- Adds Character model with survival needs (hunger, thirst, energy) and state machine - Implements city:tick world ticker for offline progression every minute - Adds city territory expansion and building construction system - Introduces job economy, inventory, and transaction audit trail - Adds social graph (friends, marriage, children) and character chat - Implements admin approval workflow for new registrations - Adds hospital admission system for traffic accidents - Includes comprehensive feature tests and world seeders
56 lines
1.6 KiB
PHP
Executable File
56 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\User;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
/**
|
|
* Ensures the authenticated account is still active and approved.
|
|
*
|
|
* Blocks banned/disabled accounts and routes pending registrations to the
|
|
* approval wait screen, even when a previously issued token or session remains.
|
|
*/
|
|
class EnsureUserIsActive
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param Closure(Request): (Response) $next
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
$user = $request->user();
|
|
|
|
if ($user !== null && $user->status !== User::STATUS_ACTIVE) {
|
|
if ($request->expectsJson()) {
|
|
return response()->json([
|
|
'message' => $user->status === User::STATUS_PENDING
|
|
? __('auth.pending')
|
|
: __('auth.disabled'),
|
|
], 403);
|
|
}
|
|
|
|
if ($user->status === User::STATUS_PENDING) {
|
|
if ($request->routeIs('account.pending', 'terms.accept', 'terms.accept.store', 'logout')) {
|
|
return $next($request);
|
|
}
|
|
|
|
return redirect()->route('account.pending');
|
|
}
|
|
|
|
auth()->guard('web')->logout();
|
|
$request->session()->invalidate();
|
|
$request->session()->regenerateToken();
|
|
|
|
return redirect()->route('login')->withErrors([
|
|
'email' => __('auth.disabled'),
|
|
]);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|