public function addUser($uid) { Wind::import('SRC:service.user.srv.PwLoginService'); $srv = new PwLoginService(); $result = $srv->sysUser($uid); if ($result instanceof PwError) { return $result->getError(); } return true; }
public function synLogin($uid) { Wind::import('SRC:service.user.bo.PwUserBo'); Wind::import('SRC:service.user.srv.PwLoginService'); $userBo = new PwUserBo($uid); if ($userBo->isExists() && !Pw::getstatus($userBo->info['status'], PwUser::STATUS_UNACTIVE)) { $srv = new PwLoginService(); $ip = Wind::getApp()->getRequest()->getClientIp(); $srv->setLoginCookie($userBo, $ip, 1); } exit; //return true; }
/** * 检查用户信息合法性 * * @return string */ private function checkUserInfo() { $identify = $this->getInput('_statu', 'get'); !$identify && ($identify = $this->getInput('_statu', 'post')); if (!$identify) { $this->showError('USER:illegal.request'); } list($identify, $url, $rememberme) = explode('|', base64_decode($identify) . '|'); list($uid, $password) = PwLoginService::parseLoginIdentify(rawurldecode($identify)); // $info = $this->_getUserDs()->getUserByUid($uid, PwUser::FETCH_MAIN); $this->loginUser = new PwUserBo($uid); if (!$this->loginUser->isExists() || Pw::getPwdCode($this->loginUser->info['password']) != $password) { $this->showError('USER:illegal.request'); } return base64_encode($identify . '|' . $url . '|' . $rememberme); }
/** * 完成注册,显示欢迎信息 */ public function welcomeAction() { if (!$this->getInput('_statu')) { $this->forwardRedirect(WindUrlHelper::createUrl('u/register/run')); } $statu = $this->checkRegisterUser(); if (Pw::getstatus($this->loginUser->info['status'], PwUser::STATUS_UNACTIVE)) { $this->forwardAction('u/register/sendActiveEmail', array('_statu' => $statu), true); } Wind::import('SRV:user.srv.PwLoginService'); $login = new PwLoginService(); $login->setLoginCookie($this->loginUser, $this->getRequest()->getClientIp()); $this->forwardRedirect(WindUrlHelper::createUrl('u/register/guide')); }
function bind_user($uid = 0) { if ($uid == 0) { $uid = $this->get_uid(); } Wind::import('SRV:user.srv.PwLoginService'); $service = new PwLoginService(); //$this->runHook('c_login_dorun', $login); Windid::load('user.WindidUser'); $info = $service->sysUser($uid); $identity = PwLoginService::createLoginIdentify($info); $identity = base64_encode($identity); $userService = Wekit::load('user.srv.PwUserService'); $userService->updateLastLoginData($info['uid'], $this->getRequest()->getClientIp()); $userService->createIdentity($info['uid'], $info['password']); //到主页去 $this->forwardRedirect(WindUrlHelper::createUrl('app/4tschool/index/run')); $this->showMessage('欢迎回来…', '/'); }
public function shopLoginAction() { $username = $this->getInput('username'); $password = $this->getInput('password'); $schoolid = $this->getInput("schoolid"); $baiduuserid = $this->getInput("baidu_userid"); $baiduchannelid = $this->getInput("baidu_channelid"); //1st, check user name and password $result = array(); $result['Success'] = 1; $result['ErrorMessage'] = ""; $result['User'] = array(); $login = new PwLoginService(); $isSuccess = $login->login($username, $password, $this->getRequest()->getClientIp(), $question, $answer); if ($isSuccess instanceof PwError) { $error = $isSuccess->getError(); $result['Success'] = -1; $message = ""; switch ($error[0]) { case 'USER:login.error.pwd': $message = "登录失败, 密码错误"; break; case 'USER:login.error.tryover.pwd': $message = "密码错误5次, 账户已被锁"; break; default: $message = "登录失败,请检查用户名或密码"; break; } $result['ErrorMessage'] = $message; $result['ErrorCode'] = $error[0]; $result['User'] = null; $result['ShopId'] = null; return $this->output($result); } else { //check if it is school's shop account $uid = $isSuccess['uid']; $exists = $this->_getSchoolPeopleDS()->checkIfAccount($uid, "shopaccount"); if ($exists == false) { $result['Success'] = -1; $message = "此帐号非商家帐号"; $result['ErrorMessage'] = $message; $result['User'] = null; $result['ShopId'] = null; return $this->output($result); } //check if relates to shop $shopid = $this->_getShopDs()->getOneShopIdbyUid($uid); $baiduUserChannelArr = array('shopid' => $shopid['id'], 'baiduuserid' => $baiduuserid, 'channelid' => $baiduchannelid); $ifexist = $this->_getBaiduuserchannelDs()->baiduchannelifexist($baiduUserChannelArr); if ($ifexist == false) { $this->_getBaiduuserchannelDs()->addBaiduuserChannelMsg($baiduUserChannelArr); } if (empty($shopid)) { $result['Success'] = -1; $message = "未绑定商家"; $result['ErrorMessage'] = $message; $result['User'] = null; $result['ShopId'] = null; return $this->output($result); } $result['Success'] = 1; $result['ErrorMessage'] = ""; $result['ShopId'] = $shopid['id']; $result['User'] = $this->getUserInfo($uid); $this->output($result); } }
public function makeOrderAction() { //get data $merchandisesInfo = $this->getInput("merchandisesInfo", "post"); $id = $this->getInput("id", "post"); $to = $this->getInput("orderContactor", "post"); $phone = $this->getInput("orderPhone", "post"); $address = $this->getInput("orderAddress", "post"); $note = $this->getInput("orderRemark", "post"); $orderExpressTime = $this->getInput("orderExpressTime", "post"); $orderHour = $this->getInput('orderHour', "post"); $orderMinutes = $this->getInput('orderMinutes', "post"); $orderTime = $orderHour . ':' . $orderMinutes; $schoolId = $this->getCurrentSchoolId(); if (empty($merchandisesInfo)) { //show not correct message return; } else { $merchandisesInfo = (array) json_decode($merchandisesInfo); } $to = trim($to); $phone = trim($phone); $address = trim($address); if (empty($to) || empty($phone) || empty($address)) { echo '无效的数据'; die; } $orderItems = $merchandisesInfo['merchandises']; $shopDeduct = array(); //calculate the promo $orderMerchandiseList = $this->jcart->get_contents(); $promos = $this->_getPromoDs()->matchedPromoInCart($orderMerchandiseList); //calculate deduct price foreach ($promos['Match'] as $item) { if ($item['ShopId'] == $shopid) { $shopDeduct['ShopId'] += $item['Deduct']; } } $hasException = false; $userid = $this->loginUser->uid; $this->_getOrderAddressDs()->addorUpdateOrderAddress($id, $userid, $to, $address, $phone); $newCreated = false; if ($userid <= 0) { //generate tmp userid $newInfo = $this->_getTmpUserDS()->registerTmpUser(1); $userid = $newInfo['uid']; $newCreated = true; } try { //start transaction $this->_getMyOrderDS()->startTran(); $generatedIds = $this->_getMyOrderDS()->makeOrder($userid, $schoolId, $orderItems, $to, $phone, $address, $note, '网站'); } catch (Exception $e) { $hasException = true; $this->_getMyOrderDS()->rollBack(); } if ($hasException == false) { $message = "下单成功"; $this->_getMyOrderDS()->commit(); } else { $message = "下单失败,请联系系统管理员"; } //清空购物车 $this->jcart->empty_cart(); if ($newCreated == true) { Wind::import('SRV:user.srv.PwLoginService'); $service = new PwLoginService(); Windid::load('user.WindidUser'); $info = $service->sysUser($userid); $identity = PwLoginService::createLoginIdentify($info); $identity = base64_encode($identity); $userService = Wekit::load('user.srv.PwUserService'); $userService->createIdentity($info['uid'], $info['password']); //跳转到我的订单的画面 $this->forwardRedirect(WindUrlHelper::createUrl('app/4tschool/schoolorder/myorder', array("message" => $message))); } else { //跳转到我的订单的画面 $this->forwardRedirect(WindUrlHelper::createUrl('app/4tschool/schoolorder/myorder', array("message" => $message))); } }
public function dorunAction() { $userForm = $this->_getLoginForm(); /* [验证验证码是否正确] */ if ($this->_showVerify()) { $veryfy = $this->_getVerifyService(); if ($veryfy->checkVerify($userForm['code']) !== true) { $this->showError('USER:verifycode.error'); } } $question = $userForm['question']; if ($question == -4) { $question = $this->getInput('myquestion', 'post'); } /* [验证用户名和密码是否正确] */ $login = new PwLoginService(); $this->runHook('c_login_dorun', $login); $isSuccess = $login->login($userForm['username'], $userForm['password'], $this->getRequest()->getClientIp(), $question, $userForm['answer']); if ($isSuccess instanceof PwError) { $this->showError($isSuccess->getError()); } $config = Wekit::C('site'); if ($config['windid'] != 'local') { $localUser = $this->_getUserDs()->getUserByUid($isSuccess['uid'], PwUser::FETCH_MAIN); if ($localUser['username'] && $userForm['username'] != $localUser['username']) { $this->showError('USER:user.syn.error'); } } Wind::import('SRV:user.srv.PwRegisterService'); $registerService = new PwRegisterService(); $info = $registerService->sysUser($isSuccess['uid']); if (!$info) { $this->showError('USER:user.syn.error'); } $identity = PwLoginService::createLoginIdentify($info); // dump($_GET); // exit; if (isset($_GET['backurl'])) { $backurl = $_GET['backurl']; } else { $backurl = 'index.php?m=app&app=nanatools'; } // $identity = base64_encode($identity . '|' . $this->getInput('backurl') . '|' . $userForm['rememberme']); $identity = base64_encode($identity . '|' . $backurl . '|' . $userForm['rememberme']); /* [是否需要设置安全问题] */ /* @var $userService PwUserService */ $userService = Wekit::load('user.srv.PwUserService'); //解决浏览器记录用户帐号和密码问题 if ($isSuccess['safecv'] && !$question) { $this->addMessage(true, 'qaE'); $this->showError('USER:verify.question.empty'); } //该帐号必须设置安全问题 if (empty($isSuccess['safecv']) && $userService->mustSettingSafeQuestion($info['uid'])) { $this->addMessage(array('url' => WindUrlHelper::createUrl('u/login/setquestion', array('v' => 1, '_statu' => $identity))), 'check'); } // $this->showMessage('http://taita.xyz/upload/index.php?m=u&c=login&a=welcome&_statu=' . $identity); header("location: index.php?m=u&c=login&a=welcome&_statu=" . $identity); // $this->showMessage('123', 'u/login/welcome?_statu=' . $identity); // exit; }
public function simpleUserInfoAction() { $username = $this->getInput("username", "get"); $passwd = $this->getInput("password", "get"); Wind::import('SRV:user.srv.PwLoginService'); /* PwLoginService()说明:只能使用5次 可以在:全局->注册登录->登录设置->密码尝试次数中修改 */ $login = new PwLoginService(); $isSuccess = $login->login($username, $passwd, NULL); if ($isSuccess instanceof PwError) { echo json_encode("0"); exit; } $uid = $isSuccess['uid']; $username = $isSuccess['username']; $avatarPath = Pw::getAvatar($uid); //获取头像 √ $response_json['uid'] = $uid; $response_json['username'] = $username; $response_json['avatarPath'] = $avatarPath; echo json_encode($response_json); exit; }