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


PHP UserAccount::getUserByUsernameAndPassword方法代碼示例

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


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

示例1: __construct

 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct();
     if (!Core::getUser() instanceof UserAccount && get_class($this) !== 'LoginController') {
         if (isset($_REQUEST['user']) && isset($_REQUEST['pass']) && in_array(get_class($this), array('OrderPrintController', 'POPrintController')) && ($userAccount = UserAccount::getUserByUsernameAndPassword(trim($_REQUEST['user']), trim($_REQUEST['pass']), true)) instanceof UserAccount) {
             Core::setUser($userAccount);
         } else {
             $this->getResponse()->Redirect('/login.html');
         }
     }
 }
開發者ID:larryu,項目名稱:magento-b2b,代碼行數:14,代碼來源:BPCPageAbstract.php

示例2: _login

 /**
  * login a user
  *
  * @param array $params
  *
  * @throws Exception
  * @return multitype:
  */
 private function _login($params)
 {
     if (!isset($params['username']) || ($username = trim($params['username'])) === '') {
         throw new Exception('username is empty!');
     }
     if (!isset($params['password']) || ($password = trim($params['password'])) === '') {
         throw new Exception('password is empty!');
     }
     $userAccount = UserAccount::getUserByUsernameAndPassword($username, $password, true);
     $role = null;
     if (count($roles = $userAccount->getRoles()) > 0) {
         $role = $roles[0];
     }
     Core::setUser($userAccount, $role);
     return array();
 }
開發者ID:larryu,項目名稱:magento-b2b,代碼行數:24,代碼來源:APIUserAccountService.php

示例3: validateUser

 /**
  * validate a user providing $username and $password
  *
  * @param string $username
  * @param string $password
  * @return true, if there is such a userAccount in the database;otherwise, false;
  */
 public function validateUser($username, $password)
 {
     if (!Core::getUser() instanceof UserAccount) {
         $userAccount = UserAccount::getUserByUsernameAndPassword($username, $password);
         if (!$userAccount instanceof UserAccount) {
             return false;
         }
         $role = null;
         if (!Core::getRole() instanceof Role) {
             if (count($roles = $userAccount->getRoles()) > 0) {
                 $role = $roles[0];
             }
         }
         Core::setUser($userAccount, $role);
     }
     return true;
 }
開發者ID:larryu,項目名稱:magento-b2b,代碼行數:24,代碼來源:WebUserManager.php

示例4: login

 /**
  * Logs in a user with the given username and password POSTed. Though true
  * REST doesn't believe in sessions, it is often desirable for an AJAX server.
  *
  * @url POST /login
  */
 public function login()
 {
     try {
         $username = trim($_POST['username']);
         if ($username === '') {
             throw new AuthenticationException("Empty username not allowed");
         }
         $password = trim($_POST['password']);
         if ($password === '') {
             throw new AuthenticationException("Empty password not allowed");
         }
         $userAccount = UserAccount::getUserByUsernameAndPassword($username, $password);
         if ($userAccount instanceof UserAccount) {
             Core::getUser($userAccount);
         }
     } catch (Exception $ex) {
         throw new RestException(401, $ex->getMessage(), $ex);
     }
     return array("success" => "Logged in " . $username);
 }
開發者ID:helin16,項目名稱:pricematch,代碼行數:26,代碼來源:UserController.php


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