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


PHP CPasswordHelper::verifyPassword方法代码示例

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


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

示例1: authenticate

 /**
  * Authentication
  * @return bool
  */
 public function authenticate()
 {
     /** @var AccountModule $account */
     $account = Yii::app()->getModule('account');
     /** @var AccountUser $user */
     $user = CActiveRecord::model($account->userClass)->find('(LOWER(username)=? OR LOWER(email)=?)', array(strtolower($this->username), strtolower($this->username)));
     if (!$user) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
         return false;
     }
     if ($account->activatedField && !$user->{$account->activatedField}) {
         $this->errorCode = self::ERROR_NOT_ACTIVATED;
         return false;
     }
     if ($account->disabledField && $user->{$account->disabledField}) {
         $this->errorCode = self::ERROR_DISABLED;
         return false;
     }
     if (!$this->skipPassword && !CPasswordHelper::verifyPassword($this->password, $user->{$account->passwordField})) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         return false;
     }
     $this->_id = $user->primaryKey;
     $this->username = $account->usernameField && $user->{$account->usernameField} ? $user->{$account->usernameField} : $user->{$account->emailField};
     $this->errorCode = self::ERROR_NONE;
     return true;
 }
开发者ID:cornernote,项目名称:yii-account-module,代码行数:31,代码来源:AccountUserIdentity.php

示例2: checkOldPassword

 /**
  * 
  * @param unknown $attribute
  * @param unknown $params
  */
 public function checkOldPassword($attribute, $params)
 {
     $user = User::model()->findByAttributes(array('id' => Yii::app()->user->getId()));
     if (!empty($this->oldPassword) && !CPasswordHelper::verifyPassword($this->oldPassword, $user->password)) {
         $this->addError('oldPassword', Yii::t('ProfileModule.password', 'error.password.oldPasswordWrong'));
     }
 }
开发者ID:bafio89,项目名称:qea-u,代码行数:12,代码来源:ChangePasswordForm.php

示例3: authenticate

 public function authenticate()
 {
     $user = User::model()->with('service')->find('username=:u', ['u' => $this->username]);
     $verifyPassword = false;
     if (empty($user)) {
         $state = 1;
     } else {
         $verifyPassword = CPasswordHelper::verifyPassword($this->password, $user->password);
         $state = $verifyPassword ? 0 : 1;
     }
     $result = Fraudmetrix::login($this->username, $state);
     if ($result['success'] == true && $result['final_decision'] == 'Reject') {
         $this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
         $this->errorMessage = '未知错误';
     } else {
         if (empty($user)) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
             $this->errorMessage = '用户邮箱不存在';
         } else {
             if ($user->state == 1) {
                 $this->errorCode = self::ERROR_NOT_LOGIN;
                 $this->errorMessage = '登录账号已被锁定';
             } elseif (!$verifyPassword) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
                 $this->errorMessage = '用户密码错误';
             } else {
                 $server = Setting::model()->get('wakfu', 'server');
                 $this->errorCode = self::ERROR_NONE;
                 $this->setPersistentStates(array_merge($user->getAttributes(), ['last_login_time' => $user->last_login_time, 'last_login_ip' => $user->last_login_ip, 'sign_up_time' => $user->sign_up_time, 'sign_up_ip' => $user->sign_up_ip, 'server' => $server[$user->service->server], 'port' => $user->service->port]));
                 $this->afterLogin($user);
             }
         }
     }
     return !$this->errorCode;
 }
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:35,代码来源:UserIdentity.php

示例4: authenticate

 public function authenticate()
 {
     $record = User::model()->findByAttributes(array('username' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!CPasswordHelper::verifyPassword($this->password, $record->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $access = AccessGlobal::getAction($record->role == 'superadmin' ? '0' : '1');
             if ($record->role == 'user') {
                 $access['site'] = array_intersect($access['site'], AccessGlobal::getActionFromArrayId(AccessUser::getActionIdFromUser($record->user_id)));
             }
             if ($record->role == 'admin') {
                 $access['site'] = array_intersect($access['site'], AccessGlobal::getActionFromArrayId(AccessUser::getActionIdFromUser($record->user_id)));
             }
             $this->_id = $record->user_id;
             $this->setState('role', $record->role);
             $this->setState('name', $this->username);
             $this->setState('access', $access);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
开发者ID:anton-itscript,项目名称:WM,代码行数:25,代码来源:UserIdentity.php

示例5: confirm

 public function confirm($attrbutes, $params)
 {
     $user = User::model()->findByPk(Yii::app()->user->getId());
     if (!CPasswordHelper::verifyPassword($this->oldPassword, $user->password)) {
         $this->addError($attrbutes, $params['message']);
     }
 }
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:7,代码来源:UserForm.php

示例6: validatePassword

 public function validatePassword($user)
 {
     if ($user->password) {
         return CPasswordHelper::verifyPassword($this->password, $user->password);
     }
     return true;
 }
开发者ID:KEMSolutions,项目名称:Boukem1,代码行数:7,代码来源:UserIdentity.php

示例7: actionCambiarClave

 public function actionCambiarClave()
 {
     $form = new CambiarClaveForm();
     if (isset(Yii::app()->user->id)) {
         if (isset($_POST['CambiarClaveForm'])) {
             $form->attributes = $_POST['CambiarClaveForm'];
             if ($form->validate()) {
                 $new_password = Usuario::model()->findByPk(Yii::app()->user->id);
                 if (!CPasswordHelper::verifyPassword($form->clave, $new_password->clave)) {
                     $form->addError('clave', "clave incorrecta");
                 } else {
                     if ($form->nueva == $form->repita) {
                         $new_password->clave = CPasswordHelper::hashPassword($form->nueva);
                         if ($new_password->save()) {
                             Yii::app()->user->setFlash('profileMessage', "Clave cambiada correctamente.");
                         } else {
                             Yii::app()->user->setFlash('profileMessage', "No se pudo cambiar la clave, inténtelo de nuevo más tarde.");
                         }
                         $this->refresh();
                     } else {
                         $form->addError('nueva', "claves nuevas no coinciden");
                         $form->addError('repita', "claves nuevas no coinciden");
                     }
                 }
             }
         }
         $this->render('//site/cambiarClave', array('model' => $form));
     }
 }
开发者ID:crmoya,项目名称:inmobiliaria,代码行数:29,代码来源:SiteController.php

示例8: authenticate

 public function authenticate()
 {
     $user = Yii::app()->controller->user;
     if (CPasswordHelper::verifyPassword($this->password, $user->password) === false) {
         $this->addError('password', 'Error password');
     }
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:7,代码来源:ChangePasswordForm.php

示例9: authenticate

 /**
  * Overrides the parent method.
  * 
  * @return integer Returns the error code.
  */
 public function authenticate()
 {
     $this->errorCode = self::ERROR_NONE;
     if (isset($this->username) && isset($this->password)) {
         $this->user = User::model()->findByAttributes(array('email' => $this->username));
         if (isset($this->user)) {
             if ($this->user->status == User::STATUS_ACTIVE) {
                 if (CPasswordHelper::verifyPassword($this->password, $this->user->password)) {
                     Yii::app()->user->login($this);
                     //TODO: write a log here
                 } else {
                     $this->errorCode = self::ERROR_PASSWORD_INVALID;
                     //TODO: write a log here
                 }
             } else {
                 $this->errorCode = self::ERROR_USERNAME_INACTIVE;
                 //TODO: write a log here
             }
         } else {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
             //TODO: write a log here
         }
     }
     return $this->errorCode;
 }
开发者ID:bafio89,项目名称:qea-u,代码行数:30,代码来源:BasicUserIdentity.php

示例10: authenticate

 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         if (!CPasswordHelper::verifyPassword($this->old_password, Yii::app()->user->user->password)) {
             $this->addError('old_password', Yii::t("app", "Le mot de passe actuel entré est incorrect."));
         }
     }
 }
开发者ID:KEMSolutions,项目名称:Boukem1,代码行数:12,代码来源:UpdatePasswordForm.php

示例11: compareOldPassword

 public function compareOldPassword($attribute)
 {
     //return($old->password === Yii::app()->digester->md5($_password));
     $userlogin = User::model()->findByPk($this->id);
     if (CPasswordHelper::verifyPassword($this->{$attribute}, $userlogin->password)) {
         return TRUE;
     } else {
         $this->addError('oldpassword', 'Password Lama yang anda masukkan salah');
     }
 }
开发者ID:jordan095,项目名称:kpu-iadel,代码行数:10,代码来源:UpdatePasswordForm2.php

示例12: authenticate

 public function authenticate()
 {
     $user = User::model()->findByAttributes(array('email' => $this->username, 'status' => array(User::STATUS_NORMAL, User::STATUS_BANNED)));
     if ($user === null || CPasswordHelper::verifyPassword($this->password, $user->password) === false) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->id = $user->id;
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:11,代码来源:UserIdentity.php

示例13: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     /** @var User $user */
     $user = User::model()->findByAttributes(array('username' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!CPasswordHelper::verifyPassword($this->password, $user->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $user->id;
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
开发者ID:yakleg,项目名称:gosbroker,代码行数:22,代码来源:UserIdentity.php

示例14: authenticate

 public function authenticate()
 {
     $record = User::model()->findByAttributes(['username' => $this->username]);
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!CPasswordHelper::verifyPassword($this->password, $record->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->id;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
开发者ID:tdimdimich,项目名称:wililhill.com,代码行数:15,代码来源:PasswordIdentity.php

示例15: authenticate

 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = User::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!CPasswordHelper::verifyPassword($this->password, $user->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->username = $user->username;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
开发者ID:ho96,项目名称:yii-admin,代码行数:20,代码来源:UserIdentity.php


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