Exemplo n.º 1
0
 public function mobilenumactiveAction()
 {
     $deploy_mode = $this->container->getParameter('deploy_mode');
     $request = $this->getRequest();
     $mobile_num = $request->get('mobile_num');
     $mobile_pwd = $request->get('mobile_pwd');
     //$eno = $request->get('eno');
     $eno = $deploy_mode == "C" ? Utils::$PUBLIC_ENO : $this->container->getParameter("ENO");
     //企业独立部署时企业不设置,从配置文件中获取固定的企业号
     $ename = $request->get('ename');
     $nick_name = $request->get('nick_name');
     $active_code = $request->get('active_code');
     $login_account = $mobile_num;
     $ldap_uid = $request->get("ldap_uid");
     if (empty($active_code)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "请输入短信验证码!");
     }
     if (empty($mobile_pwd)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "请输入密码!");
     }
     if (empty($nick_name)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "请输入姓名!");
     }
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $cacheobj = new \Justsy\BaseBundle\Management\Enterprise($da, $this->get("logger"), $this->container);
     if (!strpos($login_account, "@")) {
         $domain = $this->container->getParameter('edomain');
         $login_account .= "@" . $domain;
     }
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->get("logger"), $this->container);
     $had = $staffMgr->getInfo();
     if (!empty($had)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已注册,继续使用请先找回密码");
     }
     //判断手机号是否已经被使用
     if ($staffMgr->checkUser($mobile_num)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已被绑定,请解绑后重试");
     }
     $sysparam = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $wn_code = $sysparam->GetSysParam("mobile_active_code");
     try {
         if ($wn_code != $active_code) {
             $sql = "select state_id,active_code,review_note from we_register where login_account=?";
             $ds = $da->GetData("we_register", $sql, array($login_account));
             if ($ds && $ds['we_register']['recordcount'] <= 0) {
                 return $this->getResponse(ReturnCode::$OTHERERROR, "未找到该手机号的注册信息!");
             }
             if ($ds['we_register']['rows'][0]['state_id'] == '3') {
                 return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已被注册!");
             }
             if ((empty($ds['we_register']['rows'][0]['review_note']) ? 0 : $ds['we_register']['rows'][0]['review_note']) >= 5) {
                 return $this->getResponse(ReturnCode::$OTHERERROR, "抱歉,验证码请求次数过多,如果获取不到验证码请根据下方提示与我们联系");
             }
             if ($ds['we_register']['rows'][0]['active_code'] != $active_code) {
                 $num = 5 - (empty($ds['we_register']['rows'][0]['review_note']) ? 0 : $ds['we_register']['rows'][0]['review_note']);
                 $sql = "update we_register set review_note=ifnull(review_note,0)+1 where login_account=?";
                 $da->ExecSQL($sql, array($login_account));
                 return $this->getResponse(ReturnCode::$OTHERERROR, "验证码错误,请重新输入。");
             }
         }
         $para = array();
         $para['account'] = $mobile_num;
         $para['password'] = $mobile_pwd;
         $para['deptid'] = '';
         $para['nick_name'] = $nick_name;
         $para['ldap_uid'] = '';
         $re = $staffMgr->createstaff($para);
     } catch (\Exception $e) {
         $re = Utils::WrapResultError($e->getMessage());
     }
     return $this->getResponse($re['returncode'], $re['msg']);
 }
Exemplo n.º 2
0
 public function TencentLoginAction()
 {
     $da = $this->get("we_data_access");
     $request = $this->getRequest();
     $openid = $request->get("openid");
     //普通用户的标识,对当前开发者帐号唯一
     $logintype = $request->get("logintype");
     $logintype = empty($logintype) ? "02" : $logintype;
     $ldap_uid = "";
     $login_account = $openid . "@fafatime.com";
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $login_account, $this->get("logger"), $this->container);
     $staffdata = $staffMgr->getInfo();
     $re = array("returncode" => ReturnCode::$SYSERROR, "msg" => "");
     $password = "";
     //账号为空表示不存在
     if (empty($staffdata)) {
         $sex = $request->get("gender");
         if (trim($sex) == "男") {
             $sex = 1;
         } else {
             if (trim($sex) == "女") {
                 $sex = 2;
             } else {
                 $sex = 0;
             }
         }
         $parameter = array("appid" => $request->get("appid"), "province" => $request->get("province"), "city" => $request->get("city"), "account" => $login_account, "nick_name" => $request->get("nickname"), "eno" => $request->get("eno"), "ldap_uid" => $openid, "openid" => $openid, "sex" => $sex, "headimgurl" => $request->get("figureurl_2"), "type" => "tencent");
         $registerInfo = $staffMgr->createstaff($parameter);
         if ($registerInfo["returncode"] == ReturnCode::$SUCCESS) {
             $re = $this->autologin($login_account, $logintype);
         } else {
             $re = $registerInfo;
         }
     } else {
         $re = $this->autologin($login_account, $logintype);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Exemplo n.º 3
0
 public static function tokenAction($container, $con, $appid, $code, $encrypt)
 {
     $app = new \Justsy\BaseBundle\Management\App($container->container);
     $stat_v = explode(",", $appid);
     $appid = $stat_v[0];
     $openid = $stat_v[1];
     $isLogin = null;
     if (strpos($appid, "SSO_") !== false) {
         $isLogin = $appid;
         //新浪微博集成登录
         //获取微博对应的业务系统认证配置
         $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($container);
         $appid = $syspara->GetSysParam(strtolower($appid) . "_appid");
         if (empty($appid)) {
             $resp = new Response("未配置微博业务系统或参数sso_sina_appid");
             $resp->headers->set('Content-Type', 'text/html');
             return $resp;
         }
         $appdata = $app->getbussysteminfo(array("appid" => $appid));
         $appid = $isLogin;
         //把appid还原成sso集成登录标识
     } else {
         if (strpos($appid, "SYS_") !== false) {
             //业务系统直接对接
             $appdata = $app->getbussysteminfo(array("appid" => substr($appid, 4)));
         } else {
             $appdata = $app->getappinfo(array("appid" => $appid));
         }
     }
     if (empty($appdata)) {
         return "无效的APPID";
     }
     $token_url = $appdata["token_url"];
     if (empty($token_url)) {
         return "无效的配置:令牌获取地址无效";
     }
     $token_method = $appdata["token_method"];
     $token_method = empty($token_method) ? "POST" : $token_method;
     $auth_url = $token_url;
     $para_name = $appdata["redirecturl_para_name"];
     if (empty($para_name)) {
         $para_name = "redirect_uri";
     }
     $paraString = "";
     if (empty($code)) {
         $paraString .= "grant_type=client_credentials&" . $para_name . "=" . $appdata["redirection_url"];
     } else {
         $paraString .= "grant_type=authorization_code&" . $para_name . "=" . $appdata["redirection_url"];
     }
     $para_name = $appdata["clientid_para_name"];
     if (empty($para_name)) {
         $para_name = "client_id";
     }
     $paraString .= "&" . $para_name . "=" . $appdata["clientid"];
     $para_name = $appdata["clientkey_para_name"];
     if (empty($para_name)) {
         $para_name = "client_secret";
     }
     $paraString .= "&" . $para_name . "=" . $appdata["clientkey"];
     $paraString .= "&code=" . $code;
     $paraString .= "&state=" . $appid . "," . $openid;
     $container->get("logger")->err($auth_url . " -- " . $paraString);
     if (strtoupper($token_method) == "POST") {
         $token = Utils::do_post_request($auth_url, $paraString);
     } else {
         $token = Utils::do_post_request($auth_url . "?" . $paraString, null);
     }
     $container->get("logger")->err("token value:" . $token);
     $retuenAry = array();
     if (substr($token, 0, 1) == "{") {
         $retuenAry = json_decode($token, true);
     } else {
         $rv = explode("&", $token);
         for ($i = 0; $i < count($rv); $i++) {
             $rv_i = explode("=", $rv[$i]);
             $retuenAry[$rv_i[0]] = preg_replace("/'/is", "", $rv_i[1]);
         }
     }
     $result = array("returncode" => "0000", "data" => null);
     $para_name = $appdata["token_para_name"];
     if (empty($para_name)) {
         $para_name = "access_token";
     }
     if (isset($retuenAry[$para_name])) {
         $retuenAry[$appdata["clientid_para_name"]] = $appdata["clientid"];
         $retuenAry[$appdata["clientkey_para_name"]] = $appdata["clientkey"];
         $result["returncode"] = "0000";
         $retuenAry[$appdata["token_para_name"]] = $retuenAry[$para_name];
         $app->setappsession(array("session" => $retuenAry, "openid" => $openid, "appid" => $appid));
     } else {
         $result["returncode"] = "9999";
     }
     $result["data"] = $retuenAry;
     if (!empty($isLogin)) {
         if (strpos($isLogin, "SSO_") !== false) {
             if ($isLogin == "SSO_SINA") {
                 $uid = $retuenAry["uid"];
             } else {
                 if ($isLogin == "SSO_WECHAT") {
                     $uid = $retuenAry["openid"];
                 }
             }
             //判断并注册用户
             $staffobj = new \Justsy\BaseBundle\Management\Staff($container->get("we_data_access"), $container->get("we_data_access_im"), $uid, null, $container->container);
             $re = $staffobj->createstaff(array("password" => rand(100000, 999999), "eno" => Utils::$PUBLIC_ENO, "nick_name" => $uid, "ldap_uid" => $uid, "account" => ""));
             $re["data"]["des"] = DES::decrypt($re["data"]["t_code"]);
         }
         return self::responseLoginJson(json_encode($re));
     } else {
         if (strpos($appid, "SYS_") !== false) {
             return self::responseJsonStr(json_encode($result));
         } else {
             return self::responseJson(json_encode($result));
         }
     }
 }