當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session::isLoggedIn方法代碼示例

本文整理匯總了PHP中Magento\Backend\Model\Auth\Session::isLoggedIn方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::isLoggedIn方法的具體用法?PHP Session::isLoggedIn怎麽用?PHP Session::isLoggedIn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Backend\Model\Auth\Session的用法示例。


在下文中一共展示了Session::isLoggedIn方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testIsLoggedInWithIgnoredLifetime

 /**
  * Disabled form security in order to prevent exit from the app
  * @magentoConfigFixture current_store admin/security/session_lifetime 59
  */
 public function testIsLoggedInWithIgnoredLifetime()
 {
     $this->_auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
     $this->assertTrue($this->_model->isLoggedIn());
     $this->_model->setUpdatedAt(time() - 101);
     $this->assertTrue($this->_model->isLoggedIn());
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:11,代碼來源:SessionTest.php

示例2: match

 /**
  * Match provided request and if matched - return corresponding controller
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\Action\Action|null
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     // if URL has VDE prefix
     if (!$this->_designEditorHelper->isVdeRequest($request)) {
         return null;
     }
     // user must be logged in admin area
     if (!$this->_session->isLoggedIn()) {
         return null;
     }
     // prepare request to imitate
     $this->_prepareVdeRequest($request);
     /**
      * Deprecated line of code was here which should be adopted if needed:
      * $this->_urlRewriteService->applyRewrites($request);
      */
     // match routers
     $controller = null;
     $routers = $this->_getMatchedRouters();
     /** @var $router \Magento\Framework\App\RouterInterface */
     foreach ($routers as $router) {
         /** @var $controller \Magento\Framework\App\Action\AbstractAction */
         $controller = $router->match($request);
         if ($controller) {
             $this->_state->update(\Magento\Framework\App\Area::AREA_FRONTEND, $request);
             break;
         }
     }
     // set inline translation mode
     $this->_designEditorHelper->setTranslationMode($request);
     return $controller;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:38,代碼來源:Standard.php

示例3: execute

 /**
  * Predispath admin action controller
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->backendAuthSession->isLoggedIn()) {
         $feedModel = $this->feedFactory->create();
         $feedModel->checkUpdate();
     }
 }
開發者ID:swissup,項目名稱:core,代碼行數:13,代碼來源:FetchNotifications.php

示例4: testIsLoggedIn

 /**
  * @dataProvider loginDataProvider
  */
 public function testIsLoggedIn($loggedIn)
 {
     if ($loggedIn) {
         $this->auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
     }
     $this->assertEquals($loggedIn, $this->authSession->isLoggedIn());
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:10,代碼來源:SessionTest.php

示例5: execute

 /**
  * Predispath admin action controller
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_backendAuthSession->isLoggedIn()) {
         $feedModel = $this->_feedFactory->create();
         /* @var $feedModel \Magento\AdminNotification\Model\Feed */
         $feedModel->checkUpdate();
     }
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:15,代碼來源:PredispatchAdminActionControllerObserver.php

示例6: execute

 /**
  * Adds New Relic custom parameters per adminhtml request for current admin user, if applicable
  *
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         if ($this->backendAuthSession->isLoggedIn()) {
             $user = $this->backendAuthSession->getUser();
             $this->newRelicWrapper->addCustomParameter(Config::ADMIN_USER_ID, $user->getId());
             $this->newRelicWrapper->addCustomParameter(Config::ADMIN_USER, $user->getUsername());
             $this->newRelicWrapper->addCustomParameter(Config::ADMIN_NAME, $user->getFirstname() . ' ' . $user->getLastname());
         }
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:ReportConcurrentAdminsToNewRelic.php

示例7: execute

 /**
  * Reports concurrent admins to the database reporting_users table
  *
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         if ($this->backendAuthSession->isLoggedIn()) {
             $user = $this->backendAuthSession->getUser();
             $jsonData = ['id' => $user->getId(), 'username' => $user->getUsername(), 'name' => $user->getFirstname() . ' ' . $user->getLastname()];
             $modelData = ['type' => 'admin_activity', 'action' => $this->jsonEncoder->encode($jsonData)];
             /** @var \Magento\NewRelicReporting\Model\Users $usersModel */
             $usersModel = $this->usersFactory->create();
             $usersModel->setData($modelData);
             $usersModel->save();
         }
     }
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:21,代碼來源:ReportConcurrentAdmins.php

示例8: execute

 /**
  * Force admin to change password
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if (!$this->observerConfig->isPasswordChangeForced()) {
         return;
     }
     if (!$this->authSession->isLoggedIn()) {
         return;
     }
     $actionList = ['adminhtml_system_account_index', 'adminhtml_system_account_save', 'adminhtml_auth_logout'];
     /** @var \Magento\Framework\App\Action\Action $controller */
     $controller = $observer->getEvent()->getControllerAction();
     /** @var \Magento\Framework\App\RequestInterface $request */
     $request = $observer->getEvent()->getRequest();
     if ($this->authSession->getPciAdminUserIsPasswordExpired()) {
         if (!in_array($request->getFullActionName(), $actionList)) {
             if ($this->authorization->isAllowed('Magento_Backend::myaccount')) {
                 $controller->getResponse()->setRedirect($this->url->getUrl('adminhtml/system_account/'));
                 $this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
                 $this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_POST_DISPATCH, true);
             } else {
                 /*
                  * if admin password is expired and access to 'My Account' page is denied
                  * than we need to do force logout with error message
                  */
                 $this->authSession->clearStorage();
                 $this->session->clearStorage();
                 $this->messageManager->addErrorMessage(__('Your password has expired; please contact your administrator.'));
                 $controller->getRequest()->setDispatched(false);
             }
         }
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:38,代碼來源:ForceAdminPasswordChangeObserver.php

示例9: testLogoutAction

 /**
  * @covers \Magento\Backend\Controller\Adminhtml\Auth::logoutAction
  * @magentoDbIsolation enabled
  */
 public function testLogoutAction()
 {
     $this->_login();
     $this->dispatch('backend/admin/auth/logout');
     $this->assertRedirect($this->equalTo(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Backend\\Helper\\Data')->getHomePageUrl()));
     $this->assertFalse($this->_session->isLoggedIn(), 'User is not logged out.');
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:11,代碼來源:AuthTest.php

示例10: testIsLoggedInPositive

 public function testIsLoggedInPositive()
 {
     $user = $this->getMock('Magento\\User\\Model\\User', ['getId', '__wakeup'], [], '', false);
     $user->expects($this->once())->method('getId')->will($this->returnValue(1));
     $this->storage->expects($this->any())->method('getUser')->will($this->returnValue($user));
     $this->assertTrue($this->session->isLoggedIn());
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:7,代碼來源:SessionTest.php

示例11: isLoggedIn

 /**
  * {@inheritdoc}
  */
 public function isLoggedIn()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'isLoggedIn');
     if (!$pluginInfo) {
         return parent::isLoggedIn();
     } else {
         return $this->___callPlugins('isLoggedIn', func_get_args(), $pluginInfo);
     }
 }
開發者ID:dragonsword007008,項目名稱:magento2,代碼行數:12,代碼來源:Interceptor.php

示例12: isBackendOrder

 protected function isBackendOrder()
 {
     return $this->backendAuthSession->isLoggedIn();
 }
開發者ID:owebia,項目名稱:magento2-module-advanced-setting-core,代碼行數:4,代碼來源:AbstractWrapper.php


注:本文中的Magento\Backend\Model\Auth\Session::isLoggedIn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。