示例#1
0
 /**
  * (non-PHPdoc)
  * @see CUserIdentity::authenticate()
  * 用户认证
  * @since 1.1.1
  */
 public function authenticate()
 {
     $uerObject = new CUserValid();
     $user = $uerObject->validUser(trim($this->username), $this->password);
     //如果存在错误代码  则返回
     if (!$user) {
         $this->errorCode = $uerObject->errorCode;
         return false;
     }
     if (!isset($user) || !$user) {
         $this->errorCode = MConst::ERROR_PASSWORD_INVALID;
         if (CUserValid::$userDisabled) {
             $this->errorCode = MConst::ERROR_USER_DISABLED;
         } elseif ($uerObject->errorCode == MConst::ERROR_USERNAME_INVALID) {
             $this->errorCode = MConst::ERROR_USERNAME_INVALID;
         }
         return false;
     }
     return $this->loadUser($user);
 }
示例#2
0
 /**
  * 验证密码是否正确
  */
 private function validUser($key, $name, $cipherText)
 {
     //如果是浏览器客户端,采用明文传输密码
     if (MiniHttp::clientIsBrowser()) {
         $password = $cipherText;
     } else {
         //进行des解码解析出明文密码
         $password = MSecret::decryptHex($key, $cipherText);
     }
     //进行多用户源的验证
     $uerObject = new CUserValid();
     $user = $uerObject->validUser($name, $password);
     if (!isset($user) || !$user) {
         return false;
     }
     return $user;
 }
示例#3
0
 /**
  *  修改密码
  */
 public function updatePassword($newPassword, $password)
 {
     $userId = $this->user['id'];
     $userName = $this->user['user_name'];
     $model = new CUserValid();
     $success = $model->validUser($userName, $password);
     if ($success != false) {
         MiniUser::getInstance()->updatePassword($userId, $newPassword);
         $success = true;
     }
     return $success;
 }
示例#4
0
 /**
  * 验证自有系统中是否存在此用户
  * @param string $userName
  * @param string $password
  * @return bool $use
  */
 public function validUserSelf($userName, $password)
 {
     $user = MiniUser2::getInstance()->getUserByName2($userName);
     if ($user === NULL) {
         //用户名不存在
         $this->errorCode = MConst::ERROR_USERNAME_INVALID;
         return false;
     }
     $signPassword = MSecret::passSign($password, $user["salt"]);
     if ($user["user_pass"] == $signPassword) {
         //密码正确的情况下再验证用户是否被冻结
         if (!$user['user_status']) {
             //返回用户被冻结错误码
             CUserValid::$userDisabled = true;
             $this->errorCode = MConst::ERROR_USER_DISABLED;
             return false;
         }
         return $user;
     }
     //返回密码不正确 代码
     $this->errorCode = MConst::ERROR_PASSWORD_INVALID;
     return false;
 }