|
|
|
@ -9,7 +9,7 @@
|
|
|
|
|
namespace Eater\Glim\Handler;
|
|
|
|
|
|
|
|
|
|
use Aura\Session\Segment;
|
|
|
|
|
use Eater\Glim\Model\Base\UserQuery;
|
|
|
|
|
use Eater\Glim\Model\UserQuery;
|
|
|
|
|
use Eater\Glim\Model\User;
|
|
|
|
|
use Eater\Glim\Service\TwigVars;
|
|
|
|
|
|
|
|
|
@ -18,7 +18,7 @@ class Session extends Main
|
|
|
|
|
/**
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
protected $shouldHaveUser = false;
|
|
|
|
|
protected $shouldHaveUser = true;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var bool
|
|
|
|
@ -60,12 +60,16 @@ class Session extends Main
|
|
|
|
|
/** @var Segment $segment */
|
|
|
|
|
$segment = $session->getSegment('main');
|
|
|
|
|
/** @var User $user */
|
|
|
|
|
$user = $segment->get('user');
|
|
|
|
|
$userId = $segment->get('userId');
|
|
|
|
|
|
|
|
|
|
$user = UserQuery::create()->findOneById($userId);
|
|
|
|
|
|
|
|
|
|
$twigVar->def('user', $user);
|
|
|
|
|
|
|
|
|
|
$this->setUser($user);
|
|
|
|
|
|
|
|
|
|
if ($user === null && ($this->shouldHaveUser || $this->shouldHaveSuperuser)) {
|
|
|
|
|
$segment->set('afterLogin', $this->getRequest()->getUri());
|
|
|
|
|
return $this->redirect('/login');
|
|
|
|
|
} elseif ($this->shouldHaveSuperuser && !$user->getSuperuser()) {
|
|
|
|
|
return $this->redirect('/panel');
|
|
|
|
|