本文整理汇总了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;
}
示例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'));
}
}
示例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;
}
示例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;
}
示例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']);
}
}
示例6: validatePassword
public function validatePassword($user)
{
if ($user->password) {
return CPasswordHelper::verifyPassword($this->password, $user->password);
}
return true;
}
示例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));
}
}
示例8: authenticate
public function authenticate()
{
$user = Yii::app()->controller->user;
if (CPasswordHelper::verifyPassword($this->password, $user->password) === false) {
$this->addError('password', 'Error password');
}
}
示例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;
}
示例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."));
}
}
}
示例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');
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}