/** * Phương thức verifyPassword($attribute, $params) dùng để xác thực mật khẩu của user * * @param type $attribute * @param type $params */ public function verifyPassword($attribute, $params) { $strPassword = UserModule::encryptPassword($this->verifyPassword, $this->__user->saltkey); if ($strPassword != $this->__user->password) { $this->addError('verifyPassword', UserModule::t('The password you gave is incorrect.')); } }
/** * Phương thức authenticate() dùng để xác thực username và password của User có đúng không * * @return boolean whether authentication succeeds. */ public function authenticate() { //$record = User::model()->findByAttributes(array('username'=>$this->username)); if (strpos($this->username, "@")) { $record = User::model()->notsafe()->findByAttributes(array('email' => $this->username)); } else { $record = User::model()->notsafe()->findByAttributes(array('username' => $this->username)); } if ($record === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if ($record->password !== UserModule::encryptPassword($this->password, $record->saltkey)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $record->id; $this->setState('superuser', $record->superuser); $this->errorCode = self::ERROR_NONE; } } return !$this->errorCode; }
/** * Phương thức dùng để tạo ra mã activate code */ public function createCodeActivation() { $codeActivation = UserModule::encryptPassword(microtime(), UserModule::createSalt()); $this->activkey = $codeActivation; return $codeActivation; }