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


PHP PassHash::authenticate方法代码示例

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


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

示例1: checkOldPass

 /**
  * Check the old pass is Ok or not
  * 
  * @param array $attribute
  * @param array $params
  * @return boolean 
  */
 public function checkOldPass($attribute, $params)
 {
     $u = User::model()->findbyPk(user()->id);
     if ($u != null) {
         if (!PassHash::authenticate($this->old_password, $u->password)) {
             $this->addError($attribute, t('cms', 'Old password is not correct!'));
             return false;
         }
     } else {
         $this->addError($attribute, t('cms', 'No User Found!'));
         return false;
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:20,代码来源:UserChangePassForm.php

示例2: authenticate

 /**
  * This function check the user Authentication 
  * 
  * @return int 
  */
 public function authenticate()
 {
     // Check username based on email or username
     $username = strtolower($this->username);
     if (strpos($username, '@') !== false) {
         $user = User::model()->find('LOWER(email)=?', array($username));
     } else {
         $user = User::model()->find('LOWER(username)=?', array($username));
     }
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!PassHash::authenticate($this->password, $user->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($user->status == ConstantDefine::USER_STATUS_ACTIVE) {
                 $this->_id = $user->user_id;
                 $this->username = $user->username;
                 //If the site allow auto Login, create token to recheck for Cookies
                 if (Yii::app()->user->allowAutoLogin) {
                     $autoLoginToken = sha1(uniqid(mt_rand(), true));
                     $this->setState('autoLoginToken', $autoLoginToken);
                     $connection = Yii::app()->db;
                     //delete old keys
                     $command = $connection->createCommand('DELETE FROM {{autologin_tokens}} WHERE user_id=:user_id');
                     $command->bindValue(':user_id', $user->user_id, PDO::PARAM_STR);
                     $command->execute();
                     //set new
                     $command = $connection->createCommand('INSERT INTO {{autologin_tokens}}(user_id,token) VALUES(:user_id,:token)');
                     $command->bindValue(':user_id', $user->user_id, PDO::PARAM_STR);
                     $command->bindValue(':token', $autoLoginToken, PDO::PARAM_STR);
                     $command->execute();
                 }
                 //Start to set the recent_login time for this user
                 $user->recent_login = time();
                 $user->save();
                 //Set additional User Information
                 //Set the Error Code to None for Success
                 $this->errorCode = self::ERROR_NONE;
             } else {
                 $this->errorCode = ConstantDefine::USER_ERROR_NOT_ACTIVE;
             }
         }
     }
     unset($user);
     return $this->errorCode;
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:52,代码来源:UserIdentityDb.php


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