initialize() public method

Initialize properties.
public initialize ( array $config ) : void
$config array The config data.
return void
Exemplo n.º 1
0
 /**
  * Constructor hook method
  * @param array $config The configuration settings provided to this
  *  component
  * @return void
  * @see http://api.cakephp.org/3.3/class-Cake.Controller.Component.html#_initialize
  */
 public function initialize(array $config)
 {
     parent::initialize($config);
     //The authorization error is shown only if the user is already logged
     //  in and he is trying to do something not allowed
     if (!$this->user('id')) {
         $this->config('authError', false);
     }
 }
Exemplo n.º 2
0
 /**
  * Initialize hook method.
  *
  * @param array $config
  * @return void
  */
 public function initialize(array $config)
 {
     $this->config('loginRedirect', $this->_loginRedirect());
     $controller = $this->_registry->getController();
     $this->_controller = $controller;
     $permissions = new Permissions($this->user(), $this->request);
     $allowedActions = $permissions->getAllowed();
     $isAllowed = Arr::in($this->request->param('action'), $allowedActions);
     $this->request->offsetSet('isAllowed', $isAllowed);
     if ($this->user('role_id') == Role::ADMIN_ID) {
         $this->allow();
     } else {
         $this->allow($allowedActions);
     }
     $controller->set('loggedUser', $this->_getLoggedUserForView());
     parent::initialize($config);
 }
 /**
  * Initialize properties.
  *
  * @param array $config The config data.
  * @return void
  */
 public function initialize(array $config)
 {
     parent::initialize($config);
     $this->tfa = new TwoFactorAuth(Configure::read('TwoFactorAuth.issuer'), Configure::read('TwoFactorAuth.digits'), Configure::read('TwoFactorAuth.period'), Configure::read('TwoFactorAuth.algorithm'), Configure::read('TwoFactorAuth.qrcodeprovider'), Configure::read('TwoFactorAuth.rngprovider'));
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function initialize(array $config)
 {
     $this->config(['authenticate' => ['Form' => ['scope' => ['Users.status' => 1], 'fields' => ['username' => 'email', 'password' => 'password']]], 'loginAction' => ['plugin' => 'Pie/Users', 'controller' => 'Users', 'action' => 'login', 'prefix' => false], 'loginRedirect' => Configure::read('pie.users.auth.loginRedirect'), 'logoutRedirect' => Configure::read('pie.users.auth.logoutRedirect'), 'unauthorizedRedirect' => Configure::read('pie.users.auth.unauthorizedRedirect'), 'authError' => Configure::read('pie.users.auth.authError'), 'authorize' => ['Controller'], 'flash' => Configure::read('pie.users.auth.flash')]);
     parent::initialize($config);
     $this->config($config);
 }