Ejemplo n.º 1
0
 public function autoLoginAction()
 {
     /*退出登录*/
     $userService = Wekit::load('user.srv.PwUserService');
     if (!$userService->logout()) {
         $this->showMessage('USER:loginout.fail');
     }
     /*设置转移地址*/
     if ($this->getInput("backurl", "get")) {
         $forword_url = $this->getInput("backurl", "get");
     } else {
         $forword_url = "index.php?m=app&app=nanatools&c=show";
     }
     $auth = $this->getInput("auth", "get");
     $backurl = $this->getInput("backurl", "get");
     if (empty($auth)) {
         header("Location: " . $forword_url);
     } else {
         $base_code = base64_decode($auth);
         $user_info = explode("|", $base_code);
         // dump(count($user_info));
         if (count($user_info) == 2) {
             $username = $user_info[0];
             $passwd = $user_info[1];
         } else {
             header("Location: " . $forword_url);
         }
         /*获取identity*/
         $login = new PwLoginService();
         $u = $login->login($username, $passwd, $this->getRequest()->getClientIp(), null, null);
         if ($u instanceof PwError) {
             //这里处理账号密码错误
             // header("Location: index.php?m=app&app=nanatools&c=videomanage");
             header("Location: " . $forword_url);
             exit;
         }
         $uid = $u['uid'];
         Wind::import('SRV:user.srv.PwRegisterService');
         $registerService = new PwRegisterService();
         $info = $registerService->sysUser($uid);
         // dump($info);
         if (!$info) {
             $this->showError('USER:user.syn.error');
         }
         $identity = PwLoginService::createLoginIdentify($info);
         $identity = base64_encode($identity . '|' . $forword_url . '|');
         header("location: index.php?m=u&c=login&a=welcome&_statu=" . $identity);
     }
     exit;
 }
Ejemplo n.º 2
0
 /**
  * 页头登录
  */
 public function dologinAction()
 {
     //快捷登录功能关闭
     return;
     //
     $userForm = $this->_getLoginForm();
     $login = new PwLoginService();
     $result = Wekit::load('user.PwUser')->getUserByName($userForm['username']);
     //如果开启了验证码
     Wind::import('SRV:user.srv.PwRegisterService');
     $registerService = new PwRegisterService();
     $info = $registerService->sysUser($result['uid']);
     $identity = PwLoginService::createLoginIdentify($info);
     $backUrl = $this->getInput('backurl');
     if (!$backUrl) {
         $backUrl = $this->getRequest()->getServer('HTTP_REFERER');
     }
     $identity = base64_encode($identity . '|' . $backUrl . '|' . $userForm['rememberme']);
     $url = '';
     if ($result['safecv']) {
         $url = WindUrlHelper::createUrl('u/login/showquestion', array('_statu' => $identity));
     } elseif (Wekit::load('user.srv.PwUserService')->mustSettingSafeQuestion($info['uid'])) {
         $url = WindUrlHelper::createUrl('u/login/setquestion', array('_statu' => $identity));
     } elseif ($this->_showVerify()) {
         $url = WindUrlHelper::createUrl('u/login/showquestion', array('_statu' => $identity));
     }
     if ($url != '') {
         $url = WindUrlHelper::createUrl('u/login/run', array('_statu' => $identity));
         $this->addMessage(array('url' => ''), 'check');
         $this->showMessage('USER:login.success', 'u/login/run/?_statu=' . $identity);
         return;
     }
     //----
     $userForm = $this->_getLoginForm();
     $login = new PwLoginService();
     $result = $login->login($userForm['username'], $userForm['password'], $this->getRequest()->getClientIp());
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     } else {
         $config = Wekit::C('site');
         if ($config['windid'] != 'local') {
             $localUser = $this->_getUserDs()->getUserByUid($result['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($result['uid']);
         $identity = PwLoginService::createLoginIdentify($info);
         $backUrl = $this->getInput('backurl');
         if (!$backUrl) {
             $backUrl = $this->getRequest()->getServer('HTTP_REFERER');
         }
         $identity = base64_encode($identity . '|' . $backUrl . '|' . $userForm['rememberme']);
         if ($result['safecv']) {
             $url = WindUrlHelper::createUrl('u/login/showquestion', array('_statu' => $identity));
         } elseif (Wekit::load('user.srv.PwUserService')->mustSettingSafeQuestion($info['uid'])) {
             $url = WindUrlHelper::createUrl('u/login/setquestion', array('_statu' => $identity));
         } elseif ($this->_showVerify()) {
             $url = WindUrlHelper::createUrl('u/login/showquestion', array('_statu' => $identity));
         }
         $this->addMessage(array('url' => $url), 'check');
         $this->showMessage('USER:login.success', 'u/login/welcome?_statu=' . $identity);
     }
 }
Ejemplo n.º 3
0
 /**
  * 验证密码
  */
 public function checkpwdAction()
 {
     list($password, $username) = $this->getInput(array('password', 'username'), 'post');
     $login = new PwLoginService();
     $info = $login->login($username, $password, $this->getRequest()->getClientIp());
     if ($info instanceof PwError) {
         $this->showError($info->getError());
     }
     $this->showMessage();
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 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;
 }