当前位置: 首页>>代码示例>>PHP>>正文


PHP User::isLoggedIn方法代码示例

本文整理汇总了PHP中Nette\Security\User::isLoggedIn方法的典型用法代码示例。如果您正苦于以下问题:PHP User::isLoggedIn方法的具体用法?PHP User::isLoggedIn怎么用?PHP User::isLoggedIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Security\User的用法示例。


在下文中一共展示了User::isLoggedIn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authorize

 /**
  * @inheritdoc
  */
 public function authorize($resource, $action, $parameters = NULL)
 {
     if (!$this->user->isLoggedIn()) {
         throw new AuthorizationException('User is not logged in.');
     }
     return TRUE;
 }
开发者ID:inteve,项目名称:authorizator,代码行数:10,代码来源:UserLoggedAuthorizator.php

示例2: __invoke

 /**
  * @return mixed
  */
 public function __invoke()
 {
     if ($this->user->isLoggedIn()) {
         return $this->user->getId();
     }
     return NULL;
 }
开发者ID:darkphoenixff4,项目名称:DoctrineBehaviors,代码行数:10,代码来源:UserCallable.php

示例3: checkUser

 /**
  * @param Utils\ArrayHash $element
  *
  * @return bool
  *
  * @throws Exceptions\InvalidArgumentException
  */
 protected function checkUser(Utils\ArrayHash $element)
 {
     // Check if element has user parameter
     if ($element->offsetExists('user')) {
         // Get user parameter
         $user = $element->offsetGet('user');
         // Parameter is single string
         if (is_string($user)) {
             // User have to be logged in and is not
             if ($user == 'loggedIn' && !$this->user->isLoggedIn()) {
                 return FALSE;
                 // User have to be logged out and is logged in
             } else {
                 if ($user == 'guest' && $this->user->isLoggedIn()) {
                     return FALSE;
                 }
             }
             // Parameter have multiple definitions
         } else {
             throw new Exceptions\InvalidArgumentException('In parameter \'user\' are allowed only two strings: \'loggedIn\' & \'guest\'');
         }
         return TRUE;
     }
     return TRUE;
 }
开发者ID:srigi,项目名称:ipub-security,代码行数:32,代码来源:LatteChecker.php

示例4: checkUser

 /**
  * @param \Reflector $element
  *
  * @return bool
  *
  * @throws Exceptions\InvalidArgumentException
  */
 protected function checkUser(\Reflector $element)
 {
     // Check if element has @Secured\User annotation
     if ($element->hasAnnotation('Secured\\User')) {
         // Get user annotation
         $user = $element->getAnnotation('Secured\\User');
         // Annotation is single string
         if (is_string($user)) {
             // User have to be logged in and is not
             if ($user == 'loggedIn' && !$this->user->isLoggedIn()) {
                 return FALSE;
                 // User have to be logged out and is logged in
             } else {
                 if ($user == 'guest' && $this->user->isLoggedIn()) {
                     return FALSE;
                 }
             }
             // Annotation have multiple definitions
         } else {
             throw new Exceptions\InvalidArgumentException('In @Security\\User annotation are allowed only two strings: \'loggedIn\' & \'guest\'');
         }
         return TRUE;
     }
     return TRUE;
 }
开发者ID:cubic,项目名称:permissions,代码行数:32,代码来源:AnnotationChecker.php

示例5: checkLoggedIn

 protected function checkLoggedIn($element)
 {
     if ($element->hasAnnotation('loggedIn')) {
         return $element->getAnnotation('loggedIn') == $this->user->isLoggedIn();
     }
     return true;
 }
开发者ID:davefu,项目名称:PermissionChecker,代码行数:7,代码来源:AnnotationPermissionChecker.php

示例6: isAllowed

 /**
  * Is user allowed to perform given action with given resource.
  *
  * @param mixed
  * @param string for example 'view', 'edit'
  * @return bool
  * @throws \NetteAddons\InvalidArgumentException
  */
 public function isAllowed($resource, $action)
 {
     $moderator = $this->user->isInRole('administrators') || $this->user->isInRole('moderators');
     if ($resource instanceof Addon) {
         $ownerId = $resource->userId;
         $resource = 'addon';
     } elseif ($resource instanceof \Nette\Database\Table\ActiveRow) {
         $ownerId = $resource->user->id;
         $resource = 'addon';
     } elseif ($resource == 'page' && $action == 'manage') {
         return $moderator;
     } elseif ($resource != 'addon') {
         throw new \NetteAddons\InvalidArgumentException();
     }
     if ($resource === 'addon') {
         if ($action === 'delete' || $action === 'reports') {
             return $moderator;
         }
         if ($action === 'view') {
             return TRUE;
         } elseif ($action === 'manage') {
             return $this->user->isLoggedIn() && $ownerId === $this->user->getId() || $moderator;
         } elseif ($action === 'vote') {
             // you can't vote for your own addons
             return $this->user->isLoggedIn() && $ownerId !== $this->user->getId();
         } elseif ($action === 'create') {
             return $this->user->isLoggedIn();
         }
     }
     throw new \NetteAddons\InvalidArgumentException();
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:39,代码来源:Authorizator.php

示例7: startup

 protected function startup()
 {
     parent::startup();
     if (!$this->user->isLoggedIn()) {
         $this->flashMessage('To enter the section please log in.');
         $this->redirect(':Front:Home:Homepage:');
     }
 }
开发者ID:shophp,项目名称:shophp,代码行数:8,代码来源:BasePresenter.php

示例8: createComponentShipmentForm

 public function createComponentShipmentForm()
 {
     $form = $this->shipmentFormFactory->create($this->currentCartService->getCurrentCart()->getShipment(), $this->user->isLoggedIn() ? $this->user->getIdentity() : null);
     $form->onSuccess[] = function (ShipmentForm $form) {
         $this->updateShipment($form);
     };
     return $form;
 }
开发者ID:shophp,项目名称:shophp,代码行数:8,代码来源:ShipmentPresenter.php

示例9: actionDefault

 /**
  * @param string|null $backlink
  */
 public function actionDefault($backlink = null)
 {
     if ($this->user->isLoggedIn()) {
         $this->restoreRequest($backlink);
         $this->redirect(':Front:Home:Homepage:');
     }
     $this->backlink = $backlink;
 }
开发者ID:shophp,项目名称:shophp,代码行数:11,代码来源:RegistrationPresenter.php

示例10: onSuccessLoginForm

 public function onSuccessLoginForm()
 {
     if ($this->user->isLoggedIn()) {
         $this->user->logout(true);
     } else {
         $this->user->login($this->identity);
     }
     $this->redirect("this");
 }
开发者ID:bauer01,项目名称:fake-login,代码行数:9,代码来源:Panel.php

示例11: authenticate

 /**
  * @param Method $element
  * @throws \Flame\Rest\Security\ForbiddenRequestException
  */
 public function authenticate(Method $element)
 {
     $user = (array) $element->getAnnotation('User');
     if (in_array('loggedIn', $user)) {
         if (!$this->user->isLoggedIn()) {
             throw new ForbiddenRequestException('Please sign in.');
         }
     }
 }
开发者ID:Budry,项目名称:TinyREST,代码行数:13,代码来源:SessionAuthenticator.php

示例12: startup

 public function startup()
 {
     parent::startup();
     if ($this->user->isLoggedIn()) {
         if ($this->getParameter('id') != $this->user->getId()) {
             $this->redirect('Sign:in');
         }
     }
 }
开发者ID:04EO,项目名称:hup-nette,代码行数:9,代码来源:SecurePresenter.php

示例13: handleSave

 public function handleSave(Form $form)
 {
     if ($this->user->isLoggedIn()) {
         $form->data->route->author = $this->user->identity;
     } else {
         $form->data->author = $form['author']->getValue();
     }
     parent::handleSave($form);
 }
开发者ID:svobodni,项目名称:web,代码行数:9,代码来源:CommentFrontFormFactory.php

示例14: log

 /** Funkce pro zápis zprávy
  * 
  * @param string $message
  */
 public function log($message)
 {
     if (is_string($message) && !empty($message)) {
         $record = array('timestamp' => new DateTime(), 'message' => $message, 'ip' => $_SERVER["REMOTE_ADDR"]);
         if ($this->user && $this->user->isLoggedIn()) {
             $record['userID'] = $this->user->getIdentity()->userID;
         }
         $this->database->table(SQLLogger::DB_TABLE)->insert($record);
     }
 }
开发者ID:vipercz,项目名称:sandbox,代码行数:14,代码来源:SQLLogger.php

示例15: isGranted

 /**
  * {@inheritdoc}
  */
 public function isGranted($attributes, $object = null)
 {
     if (!is_array($attributes)) {
         $attributes = array($attributes);
     }
     if (!$this->user->isLoggedIn() || ($identity = $this->user->getIdentity()) === null) {
         $identity = new GuestIdentity();
     }
     return $this->decisionManager->decide($identity, $attributes, $object);
 }
开发者ID:zycon42,项目名称:security,代码行数:13,代码来源:SecurityContext.php


注:本文中的Nette\Security\User::isLoggedIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。