public function addUser($uid) { Wind::import('SRC:service.user.srv.PwRegisterService'); $srv = new PwRegisterService(); $result = $srv->sysUser($uid); if ($result instanceof PwError) { return $result->getError(); } return true; }
/** * 构造函数 * * @param string $username */ public function __construct($username) { /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $info = $userDs->getUserByName($username, PwUser::FETCH_MAIN | PwUser::FETCH_DATA | PwUser::FETCH_INFO); if (!$info) { $info = $this->_getWindid()->getUser($username, 2); if (!$info) { return; } Wind::import('SRV:user.srv.PwRegisterService'); $registerService = new PwRegisterService(); $info = $registerService->sysUser($info['uid']); if ($info) { $info = array_merge($info, $this->_getUserDs()->getUserByUid($info['uid'], PwUser::FETCH_INFO)); } } $this->info = $info; }
/** * 检查用户输入的用户名 */ public function checknameAction() { $login = new PwLoginService(); $info = $login->checkInput($this->getInput('username')); if (!$info) { $this->showError('USER:user.error.-14'); } if (!empty($info['safecv'])) { Wind::import('SRV:user.srv.PwRegisterService'); $registerService = new PwRegisterService(); $status = PwLoginService::createLoginIdentify($registerService->sysUser($info['uid'])); $identify = base64_encode($status . '|'); $this->addMessage($this->_getQuestions(), 'safeCheck'); $this->addMessage($identify, '_statu'); $this->showMessage(); } $this->showMessage(); }
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; }
/** * 开放帐号登录:通过第三方开放平台认证通过后,获得的帐号id在本地查找是否存在,如果存在登录成功。 * 如果没绑定第三方账号,那么结果不返回securityKey,而是返回第三方账号用户信息;否则返回securityKey以及论坛账号信息。 * @access public * @return string sessionid * @example <pre> os可以是android或者ios <br> post: access_token&platformname(qq|weibo|weixin|taobao)&native_name(回调地址) </pre> */ public function openAccountLoginAction() { $accountData = $this->authThirdPlatform(); // $accountRelationData = $this->_getUserOpenAccountDs()->getUid($accountData['uid'], $accountData['type']); //还没有绑定帐号 if (empty($accountRelationData)) { $accountData['uid'] = 0; //qq not uid $userdata = array('userinfo' => $accountData, 'laiwangSetting' => array_merge(array('laiwangOK' => false), PwLaiWangSerivce::$wk_setting)); } else { /* [验证用户名和密码是否正确] */ $login = new PwLoginService(); $this->runHook('c_login_dorun', $login); Wind::import('SRV:user.srv.PwRegisterService'); $registerService = new PwRegisterService(); $info = $registerService->sysUser($accountRelationData['uid']); if (!$info) { $this->showError('USER:user.syn.error'); } $this->uid = $info['uid']; $_userInfo = $this->_getUserAllInfo(PwUser::FETCH_MAIN + PwUser::FETCH_INFO); $laiwangOK = PwLaiWangSerivce::registerUser($this->uid, $_userInfo['password'], $_userInfo['username'], Pw::getAvatar($this->uid, 'big'), $_userInfo['gender']); PwLaiWangSerivce::updateSecret($this->uid, $_userInfo['password']); PwLaiWangSerivce::updateProfile($this->uid, $_userInfo['username'], Pw::getAvatar($this->uid, 'big'), $_userInfo['gender']); $userdata = $this->_getUserInfo($laiwangOK); } //success $this->setOutput($userdata, 'data'); $this->showMessage('USER:login.success'); }