當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。