add inline middleware to retrieve session
This commit is contained in:
parent
5f3155baa4
commit
e1b2f1806b
|
|
@ -22,7 +22,10 @@ class ClosetController extends Controller
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->closet = new Closet(session('uid'));
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->closet = new Closet($request->session()->get('uid'));
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
|
|
|||
|
|
@ -36,15 +36,21 @@ class PlayerController extends Controller
|
|||
*/
|
||||
private $player;
|
||||
|
||||
public function __construct(Request $request, UserRepository $users)
|
||||
public function __construct(UserRepository $users)
|
||||
{
|
||||
$this->user = $users->get(session('uid'));
|
||||
$this->middleware(function ($request, $next) use ($users) {
|
||||
$uid = $request->session()->get('uid');
|
||||
|
||||
if ($request->has('pid')) {
|
||||
if ($this->player = Player::find($request->pid)) {
|
||||
$this->player->checkForInvalidTextures();
|
||||
$this->user = $users->get($uid);
|
||||
|
||||
if ($request->has('pid')) {
|
||||
if ($this->player = Player::find($request->pid)) {
|
||||
$this->player->checkForInvalidTextures();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
});
|
||||
|
||||
$this->middleware([CheckPlayerExist::class, CheckPlayerOwner::class], [
|
||||
'only' => ['delete', 'rename', 'setTexture', 'clearTexture', 'setPreference']
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ class SkinlibController extends Controller
|
|||
|
||||
public function __construct(UserRepository $users)
|
||||
{
|
||||
// Try to load user by uid stored in session.
|
||||
// If there is no uid stored in session or the uid is invalid
|
||||
// it will return a null value.
|
||||
$this->user = $users->get(session('uid'));
|
||||
$this->middleware(function ($request, $next) use ($users) {
|
||||
$this->user = $users->get($request->session()->get('uid'));
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ class UserController extends Controller
|
|||
|
||||
public function __construct(UserRepository $users)
|
||||
{
|
||||
$this->user = $users->get(session('uid'));
|
||||
$this->middleware(function ($request, $next) use ($users) {
|
||||
$this->user = $users->get($request->session()->get('uid'));
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user