Inheritance: use trait Webiny\Component\StdLib\StdLibTrait, use trait Webiny\Component\Http\HttpTrait, use trait Webiny\Component\ServiceManager\ServiceManagerTrait
Esempio n. 1
0
 public function testIsUserAllowedAccessDecisionStrategyAffirmative()
 {
     // lets mock the address to one that doesn't match any rules
     Request::getInstance()->setCurrentUrl('http://admin.w3.com/about/');
     $user = new UserMock();
     $user->populate('test', 'test', [new Role('ROLE_MOCK')], true);
     $config = new ConfigObject(['DecisionStrategy' => 'affirmative', 'Rules' => [['Path' => '/^\\/about/', 'Roles' => 'ROLE_GOD']]]);
     $instance = new AccessControl($user, $config);
     $this->assertTrue($instance->isUserAllowedAccess());
 }
Esempio n. 2
0
 /**
  * Checks if current user has access to current area based by access rules.
  *
  * @return bool
  */
 public function isUserAllowedAccess()
 {
     if (!is_object($this->accessControl)) {
         $this->accessControl = new AccessControl($this->user, $this->config->get('AccessControl', false));
     }
     $isAccessAllowed = $this->accessControl->isUserAllowedAccess();
     if (!$isAccessAllowed) {
         $this->eventManager()->fire(SecurityEvent::ROLE_INVALID, new SecurityEvent($this->user));
     }
     return $isAccessAllowed;
 }