public function tologin(LoginBean $loginBean) { $ret = array('succ' => TRUE, 'errorMsg' => array()); $identifyingCodeImpl = new IdentifyingCodeBoImpl(); $identifyingCodeValid = $identifyingCodeImpl->identifyingCodeValidate($loginBean->getIdentifyingCode()); //校验验证码的合法性 if (!$identifyingCodeValid['succ']) { return $identifyingCodeValid; } $loginValid = $loginBean->isValidate(); //先验证参数的合法性 if (!$loginValid['succ']) { return $loginValid; } //验证码与参数均校验成功后进入下一步校验 $userBean = new UserBean(); $userBean->setUserID($loginBean->getUserAccount()); $userDao = $this->ci->userDao->selectOne($userBean); /** * 2 检查密码是否正确 * 3 检查用户是否存在 */ if (empty($userDao)) { $ret['succ'] = FALSE; $ret['errorMsg'] = ERROR::LOGIN_ACCOUNT_ILLEGAL; } if ($userDao->getUserPassword() === $loginBean->getUserPassword()) { $ret['succ'] = FALSE; $ret['errorMsg'] = ERROR::LOGIN_PASSWORD_FAILED; } $this->saveLoginStatus($loginBean, $ret['succ']); return $ret; }
/** * selectOne * 单一查询 * @param UserBean $userBean * @access public * @return void */ public function selectOne(UserBean $userBean) { $bean = new UserBean(); $mapping = $userBean->getMapSetting(); $ret = $this->select(implode(',', array_keys($mapping)))->where('user_id', $userBean->getUserID())->as_value()->find(); foreach ($ret as $key => $value) { $bean->setUserID($value['user_id']); $bean->setUserName($value['user_name']); $bean->setUserPassword($value['user_password']); $bean->setUserEMail($value['user_email']); } return $bean; }