当前位置: 首页>>代码示例>>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;未经允许,请勿转载。