isUserAllowedAccess() public method

Checks if current user is allowed access.
public isUserAllowedAccess ( ) : boolean
return boolean
コード例 #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());
 }
コード例 #2
0
ファイル: Firewall.php プロジェクト: Webiny/Framework
 /**
  * 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;
 }