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


PHP UserPeer::getAuthenticatedUser方法代码示例

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


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

示例1: execute

 /**
  * Execute this validator.
  *
  * @param mixed A file or parameter value/array.
  * @param error An error message reference.
  *
  * @return bool true, if this validator executes successfully, otherwise
  *              false.
  */
 public function execute(&$value, &$error)
 {
     $actionName = $this->getContext()->getActionStack()->getFirstEntry()->getActionName();
     if (isset($actionName) and 'add' == $actionName) {
         $addError = $this->getContext()->getRequest()->getError('nickname');
         if (isset($addError)) {
             $error = $addError;
             return false;
         }
         //see if there are other errors
         if (count($this->getContext()->getRequest()->getErrorNames())) {
             $error = null;
             return false;
         }
     }
     $password_param = $this->getParameterHolder()->get('password');
     $password = $this->getContext()->getRequest()->getParameter($password_param);
     $login = $value;
     // anonymous is not a real user
     if ($login == 'anonymous') {
         $error = $this->getParameterHolder()->get('login_error');
         return false;
     }
     if ($user = UserPeer::getAuthenticatedUser($login, $password)) {
         $this->getContext()->getUser()->signIn($user);
         return true;
     }
     $error = $this->getParameterHolder()->get('login_error');
     return false;
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:39,代码来源:myLoginValidator.class.php

示例2: authenticateUser

 private function authenticateUser()
 {
     if (isset($_SERVER['PHP_AUTH_USER'])) {
         if ($user = UserPeer::getAuthenticatedUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
             $this->getContext()->getUser()->signIn($user);
             return $user;
         }
     }
     header('WWW-Authenticate: Basic realm="askeet API"');
     header('HTTP/1.0 401 Unauthorized');
 }
开发者ID:emacsattic,项目名称:symfony,代码行数:11,代码来源:actions.class.php

示例3: execute

 /**
  * Execute this validator.
  *
  * @param mixed A file or parameter value/array.
  * @param error An error message reference.
  *
  * @return bool true, if this validator executes successfully, otherwise
  *              false.
  */
 public function execute(&$value, &$error)
 {
     $password_param = $this->getParameterHolder()->get('password');
     $password = $this->getContext()->getRequest()->getParameter($password_param);
     $login = $value;
     // anonymous is not a real user
     if ($login == 'anonymous') {
         $error = $this->getParameterHolder()->get('login_error');
         return false;
     }
     if ($user = UserPeer::getAuthenticatedUser($login, $password)) {
         $this->getContext()->getUser()->signIn($user);
         return true;
     }
     $error = $this->getParameterHolder()->get('login_error');
     return false;
 }
开发者ID:emacsattic,项目名称:symfony,代码行数:26,代码来源:myLoginValidator.class.php

示例4: validateUser

 /**
  * Validates a user user login
  *
  * @param string $strUsername
  * @param string $strPassword
  * @param bool $bolSetLocal Optional. Stores the validated domain and user.
  *     Default is TRUE.
  * @param bool $bolSetSession Optional. Sets the user session. Default is FALSE.
  * @param bool $bolSetCookie Optional. Default is FALSE.
  * @return User
  */
 public function validateUser($strUsername, $strPassword = false, $bolSetLocal = true, $bolSetSession = false, $bolSetCookie = false, PropelPDO $con = null)
 {
     $defaultAccountName = \Xily\Config::get('app.account', 'string', '');
     if ($defaultAccountName !== '' and strpos($strUsername, '/') === false) {
         $strUsername = $defaultAccountName . '/' . $strUsername;
     }
     $user = UserPeer::getAuthenticatedUser($strUsername, $strPassword, $con);
     if ($user === null or $user->getDeleted()) {
         return null;
     }
     if ($bolSetLocal) {
         $this->user = $user;
     }
     if ($bolSetSession) {
         $this->setUserSession($user->getId());
     }
     if ($bolSetCookie) {
         setcookie('autologin', $this->createCookieToken($user->getFQN($con), $this->cookieDuration), time() + 86400 * $this->cookieDuration);
     }
     return $user;
 }
开发者ID:dapepe,项目名称:tymio,代码行数:32,代码来源:api.class.php


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