コード例 #1
0
 /**
  * Blocks users that are either not activated or blocked.
  *
  * @param  AuthorizeEvent $event
  * @throws AuthException
  */
 public function onAuthorize(AuthorizeEvent $event)
 {
     if ($event->getUser()->isBlocked()) {
         throw new AuthException($event->getUser()->getAccess() ? __('Your account is blocked.') : __('Your account has not been activated.'));
     }
 }
コード例 #2
0
 /**
  * Checks if the user is authorized to login to administration section.
  *
  * @param  AuthorizeEvent $event
  * @throws AuthException
  */
 public function onAuthorize(AuthorizeEvent $event)
 {
     if (strpos($this['request']->get('redirect'), $this['url']->route('@system/system/admin', [], true)) === 0 && !$event->getUser()->hasAccess('system: access admin area')) {
         throw new AuthException(__('You do not have access to the administration area of this site.'));
     }
 }