public function __invoke($req, $res, $next)
 {
     // inject the request/response into auth
     $auth = $this->app['auth'];
     $auth->setRequest($req)->setResponse($res);
     $user = $auth->getAuthenticatedUser();
     // use the authenticated user as the requester for model permissions
     ACLModel::setRequester($user);
     $this->app['requester'] = $user;
     return $next($req, $res);
 }
Пример #2
0
 public function __construct($app)
 {
     // CLI requests have a super user
     if (defined('STDIN')) {
         $userClass = $this->getUserClass($app);
         $user = new $userClass(-2);
         $user->promoteToSuperUser();
         $app['user'] = $user;
         // use the super user as the requester for model permissions
         ACLModel::setRequester($user);
         $app['requester'] = $user;
     }
 }