public function run() { $schoolId = $this->getCurrentSchoolId(); $userid = $this->loginUser->uid; $myMenus = $this->_getMyOrderDS()->getMyMenus($schoolId, $userid); $this->setOutput($myMenus, 'myMenus'); //check email $code = $this->getInput('code'); $PwUserRegisterBp = new PwRegisterService(); $result = $PwUserRegisterBp->activeEmail($this->loginUser->uid, $this->loginUser->info['email'], $code); if ($result instanceof PwError) { $code = $result->getError(); $errorMessage = "验证失败,请联系管理员"; if ($code == "USER:active.email.dumplicate") { $errorMessage = "此邮箱已被验证"; } else { if ($code == "USER:illegal.request") { $errorMessage = "无效的验证请求,请联系管理员"; } else { if ($code == "USER:active.email.overtime") { $errorMessage = "验证码超时, 请再次请求"; } } } print_r($result->getError()); die; $this->showError($result->getError()); $this->setOutput(false, "validated"); } else { $this->setOutput(true, "validated"); } }
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; }
public function registerTmpUser($from = 1, $key = '') { //need to check if registered user exists or not if (empty($key) == false) { //if has key, then check if this key has user or not $tmpFound = $this->getbyKey($from, $key); if (empty($tmpFound) == false) { //if has user info, then return user's information $userid = $tmpFound['userid']; return Windid::load('user.WindidUser')->getUserByUid($userid, WindidUser::FETCH_MAIN); } } Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm(); $password = substr(md5(rand() . '123456'), 0, 15); //order number: 13 number and 3 random number $currentTimeStamp = strtotime("+0 day"); $prefix = 'tmp'; if ($from == 1) { $prefix = 'web'; } else { if ($from == 2) { $prefix = 'app'; } else { if ($from == 3) { $prefix = 'wx'; } } } $username = $prefix . rand(10, 99) . $currentTimeStamp; $userDm->setUsername($username); $userDm->setPassword($password); $userDm->setRegdate(Pw::getTime()); $userDm->setLastvisit(Pw::getTime()); $userDm->setRegip(Wekit::app()->clientIp); Wind::import('SRV:user.srv.PwRegisterService'); Wind::import('APPS:u.service.helper.PwUserHelper'); Wind::import('SRV:user.validator.PwUserValidator'); Wind::import('Wind:utility.WindValidator'); Wind::import('SRV:user.srv.PwLoginService'); $registerService = new PwRegisterService(); $registerService->setUserDm($userDm); $info = $registerService->register(); $userService = Wekit::load('user.srv.PwUserService'); $userService->updateLastLoginData($info['uid'], Wekit::app()->clientIp); $userService->createIdentity($info['uid'], $password); $dm = new App_Tmpuser_Dm(); $dm->setUserId($info['uid']); $dm->setFrom($from); $dm->setKey($key); $this->add($dm); return $info; }
/** * 构造函数 * * @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 sendEmailValidationAction() { //send validation email $registerService = new PwRegisterService(); $info = $this->loginUser->info; if (false == $registerService->checkIfActiveEmailSend($info['uid'], $info['email'])) { $this->sendEmailActive($info['username'], $info['email'], $statu, $info['uid']); } else { $this->sendEmailActive($info['username'], $info['email']); } $returnData = array("success" => true, "data" => 更新成功); print_r(json_encode($returnData)); die; }
/** * 初始化 */ private function init() { $registerService = new PwRegisterService(); $result = $registerService->checkIp($this->getRequest()->getClientIp()); if ($result instanceof PwError) { $this->showMessage($result->getError()); } $resource = Wind::getComponent('i18n'); list($_pwdMsg, $_pwdArgs) = PwUserValidator::buildPwdShowMsg(); list($_nameMsg, $_nameArgs) = PwUserValidator::buildNameShowMsg(); $this->setOutput($resource->getMessage($_pwdMsg, $_pwdArgs), 'pwdReg'); $this->setOutput($resource->getMessage($_nameMsg, $_nameArgs), 'nameReg'); $this->setOutput($this->_showVerify(), 'verify'); $this->setOutput($this->_getRegistConfig(), 'config'); $this->setOutput(PwUserHelper::getRegFieldsMap(), 'needFields'); $this->setOutput(array('location', 'hometown'), 'areaFields'); }
/** * 在 PHPWind 中注册用户、绑定用户的QQ、并返回新的Uid * @param string $mail * @param string $nick * @param &$error 传引用,如果不为空则发生了错误 * @return int uid */ function register_username($nickname, &$error = false) { !session_id() && session_start(); if (empty($_SESSION['qq_oauth_openid']) || empty($_SESSION['qq_oauth_access_token']) || empty($_SESSION['qq_oauth_figureurl_2'])) { $error = '会话丢失,请重新绑定。'; return; } else { $this->openid = $_SESSION['qq_oauth_openid']; $this->access_token = $_SESSION['qq_oauth_access_token']; } Wind::import('SRV:user.srv.PwRegisterService'); Wind::import('APPS:u.service.helper.PwUserHelper'); Wind::import('SRV:user.validator.PwUserValidator'); Wind::import('Wind:utility.WindValidator'); $registerService = new PwRegisterService(); $UserDM = $this->_UserDMUserName($nickname); $registerService->setUserDm($UserDM); if (($info = $registerService->register()) instanceof PwError) { $error = $info->getError(false); } else { if (!empty($_SESSION['qq_oauth_figureurl_2'])) { $this->restore_avatar($info['uid'], $_SESSION['qq_oauth_figureurl_2']); } return $info['uid']; } }
/** * 登录成功 */ public function welcomeAction() { $identify = $this->checkUserInfo(); if (Pw::getstatus($this->loginUser->info['status'], PwUser::STATUS_UNACTIVE)) { Wind::import('SRV:user.srv.PwRegisterService'); $identify = PwRegisterService::createRegistIdentify($this->loginUser->uid, $this->loginUser->info['password']); $this->forwardAction('u/register/sendActiveEmail', array('_statu' => $identify, 'from' => 'login'), true); } $login = new PwLoginService(); $login->welcome($this->loginUser, $this->getRequest()->getClientIp()); list(, $refUrl) = explode('|', base64_decode($identify)); if (Pw::getstatus($this->loginUser->info['status'], PwUser::STATUS_UNCHECK)) { $this->forwardRedirect(WindUrlHelper::createUrl('u/login/show', array('backurl' => $refUrl))); } if (!$refUrl) { $refUrl = Wekit::app()->baseUrl; } $config = Wekit::C('site'); if ($config['windid'] == 'local') { $this->forwardRedirect($refUrl); } else { $synLogin = $this->_getWindid()->synLogin($this->loginUser->uid); $this->setOutput($this->loginUser->username, 'username'); $this->setOutput($refUrl, 'refUrl'); $this->setOutput($synLogin, 'synLogin'); } }
/** * 用户注册信息 * * @return boolean|int */ public function userRegister($username, $password, $email) { if (!trim($username)) { return $this->buildResponse(USER_INVALID_USERNAME); } if (!$password || !$email || WindValidator::isEmail($email) !== true) { return $this->buildResponse(USER_INVALID_PARAMS); } Wind::import('SRV:user.srv.PwRegisterService'); Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm(); $userDm->setUsername($username); $userDm->setPassword($password); $userDm->setEmail($email); $userDm->setRegdate(Pw::getTime()); $userDm->setRegip(Wind::getApp()->getRequest()->getClientIp()); $registerService = new PwRegisterService(); $registerService->setUserDm($userDm); $result = $registerService->register(); if ($result instanceof PwError) { return $this->buildResponse(-1, $result->getError()); } return $this->buildResponse(0, $result); }
public function mobileLoginAction() { //simulate data $test = array("openid" => "7E561C40E3443EC7A473DB7D6767419A", "gender" => "男", "avatar" => "http://qzapp.qlogo.cn/qzapp/100505782/7E561C40E3443EC7A473DB7D6767419A/100", "nickname" => "良品-身边", "access_token" => "602E4FD23B479E8832D39AB3DAE7E5A9"); $result = array("Success" => 0, "ErrorMessage" => ""); //$testtr = json_encode($test); //$testtr = '{"openid":"7E561C40E3443EC7A473DB7D6767419A","gender":"\u7537","avatar":"","nickname":"\u826f\u54c1-\u8eab\u8fb9","access_token":"602E4FD23B479E8832D39AB3DAE7E5A9"}'; $qqInfo = $this->getInput("qqinfo"); //urldecode and jsondecode $qqInfo = urldecode($qqInfo); $qqInfo = json_decode($qqInfo); $qqInfo = $this->class_object_to_array($qqInfo); //check data empty if (empty($qqInfo)) { $result['Success'] = 0; $result['ErrorMessage'] = "无效的数据"; $this->output($result); } //1. openid //2. gender //3. avatar //4. nickname //5. access_token $openid = $qqInfo['openid']; $gender = $qqInfo['gender']; $avatar = $qqInfo['avatar']; $nickname = $qqInfo['nickname']; $access_token = $qqInfo['access_token']; if (empty($openid) || empty($nickname) || empty($access_token)) { $result['Success'] = 0; $result['ErrorMessage'] = "资料不全"; $this->output($result); } //check if this openid already has user $qqauth = Wekit::loadDao('SRC:extensions.com_qq_login.service.dao.qq_oauth_dao'); $fetched = $qqauth->getOne($openid); Wind::import('SRV:user.srv.PwRegisterService'); Wind::import('APPS:u.service.helper.PwUserHelper'); Wind::import('SRV:user.validator.PwUserValidator'); Wind::import('Wind:utility.WindValidator'); //if not registred before if (empty($fetched)) { //register user //need to rand nickname $nickname = $nickname . substr(md5(rand() . $access_token), 0, 6); $registerService = new PwRegisterService(); $UserDM = $this->_UserDMUserName($nickname); $registerService->setUserDm($UserDM); if (($info = $registerService->register()) instanceof PwError) { $error = $info->getError(false); $result['Success'] = 0; $result['ErrorMessage'] = $error; $this->output($result); } else { $uid = $info['uid']; $qqauth->add($uid, $access_token, $nickname, $avatar, $gender, 0, 0, 0, $openid); } } else { $uid = $fetched['uid']; } $result['Success'] = 1; $result['ErrorMessage'] = ""; $result['User'] = $this->getUserInfo($uid); $this->output($result); }
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; }
/** * 生成UserDM对象 * @param string $mail * @param string $nick * @return object UserDM */ private function _registerTmpUser() { Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm(); $password = substr(md5(rand() . '123456'), 0, 15); //order number: 13 number and 3 random number $currentTimeStamp = strtotime("+0 day"); $username = '******' . rand(10, 99) . $currentTimeStamp; $userDm->setUsername($username); $userDm->setPassword($password); $userDm->setRegdate(Pw::getTime()); $userDm->setLastvisit(Pw::getTime()); $userDm->setRegip(Wekit::app()->clientIp); Wind::import('SRV:user.srv.PwRegisterService'); Wind::import('APPS:u.service.helper.PwUserHelper'); Wind::import('SRV:user.validator.PwUserValidator'); Wind::import('Wind:utility.WindValidator'); Wind::import('SRV:user.srv.PwLoginService'); $registerService = new PwRegisterService(); $registerService->setUserDm($userDm); $info = $registerService->register(); $userService = Wekit::load('user.srv.PwUserService'); $userService->updateLastLoginData($info['uid'], Wekit::app()->clientIp); $userService->createIdentity($info['uid'], $password); return $info; }
/** * 开放帐号注册到本系统内 * * @access public * @return void * @example <pre> os可以是android或者ios <br> post: access_token&platformname&native_name&username&email&sex </pre> */ public function openAccountRegisterAction() { // if($this->_getUserOpenAccountDs()->addUser(56,56,56)==false){ // if(true){ // echo "true"; // $this->downloadThirdPlatformAvatar(59,"http://q.qlogo.cn/qqapp/1104230675/A773C383D93AAF2986157BA34965A5CD/100"); // }else{ // echo "false"; // } // exit; $accountData = $this->authThirdPlatform(); // list($username, $email, $sex) = $this->getInput(array('username', 'email', 'sex')); //随机密码 $password = substr(str_shuffle('abcdefghigklmnopqrstuvwxyz1234567890~!@#$%^&*()'), 0, 7); // Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm(); $userDm->setUsername($username); $userDm->setPassword($password); $userDm->setEmail($email); $userDm->setGender($sex); $userDm->setRegdate(Pw::getTime()); $userDm->setLastvisit(Pw::getTime()); $userDm->setRegip(Wind::getComponent('request')->getClientIp()); // $registerService = new PwRegisterService(); $registerService->setUserDm($userDm); /*[u_regsiter]:插件扩展*/ $this->runHook('c_register', $registerService); if (($info = $registerService->register()) instanceof PwError) { $this->showError($info->getError()); } else { // 这里注册成功,要把第三方帐号的头像下载下来并处理 // 这里取了lastInsertId,但已经指定了主键的值,所以返回false表示成功 if ($this->_getUserOpenAccountDs()->addUser($info['uid'], $accountData['uid'], $accountData['type']) == false) { $this->downloadThirdPlatformAvatar($info['uid'], $accountData['avatar']); $laiwangOK = PwLaiWangSerivce::registerUser($info['uid'], $info['username'], $info['password'], Pw::getAvatar($info['uid'], 'big'), $accountData['gender']); // 重置uid $this->uid = $info['uid']; $userdata = $this->_getUserInfo($laiwangOK); $this->setOutput($userdata, 'data'); $this->showMessage('USER:register.success'); } } }