예제 #1
0
 public function __construct($_db, $_db_im, $user, $_logger, $container)
 {
     $this->conn = $_db;
     $this->conn_im = $_db_im;
     //$this->user = $user;
     if (is_string($user)) {
         //$this->account=$user;
         $staff = new Staff($_db, $_db_im, $user, $_logger);
         $this->user = $staff->getSessionUser();
     } else {
         $this->user = $user;
     }
     $this->container = $container;
 }
예제 #2
0
 public function DeleteStaffRoleAction()
 {
     $request = $this->getRequest();
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $currUser = $this->get('security.context')->getToken();
     if (!empty($currUser)) {
         $currUser = $currUser->getUser();
     } else {
         //当应用通过api接口调用时,不用登录,只能通过openid获取人员信息
         $baseinfoCtl = new Staff($conn, null, $request->get("openid"), $this->get("logger"));
         $currUser = $baseinfoCtl->getSessionUser();
     }
     $rolecode = $request->get("rolecode");
     $staffRole = new StaffRole($conn, $conn_im, $this->get("logger"));
     $re = $staffRole->DeleteStaffRoleByCode($currUser->getUsername(), $rolecode, $currUser->getEno());
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #3
0
 public function accessCheck()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $re;
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         return Utils::WrapResultError("无效操作帐号");
     }
     return Utils::WrapResultOk($staffinfo->getSessionUser($staffdata));
 }
예제 #4
0
 public function tencentexmailloginAction()
 {
     $request = $this->getRequest();
     $param = $request->get("params");
     if (empty($param)) {
         $param = array();
     } else {
         if (is_string($param)) {
             $param = json_decode($param, true);
         }
     }
     if (!isset($param["appid"])) {
         $param["appid"] = $request->get("appid");
     }
     $openid = $request->get("openid");
     $staffObj = new \Justsy\BaseBundle\Management\Staff($this->get('we_data_access'), $this->get('we_data_access_im'), $openid, $this->get("logger"));
     $user = $staffObj->getSessionUser();
     $appid = $param["appid"];
     //$openid = $user->openid;
     //$ldap_uid = $user->ldap_uid;
     //判断是否绑定
     $app = new \Justsy\BaseBundle\Management\App($this->container);
     $appdata = $app->getappinfo(array("appid" => $appid));
     if (empty($appdata)) {
         $resp = new Response("无效的APPID");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $agent = $appdata["clientid"];
     //判断是否绑定
     $bindinfo = $app->getappbind(array("appid" => $appid, "openid" => $openid));
     if (empty($bindinfo)) {
         //$controller->get("logger")->err("================not bind");
         //重定向到绑定页面
         return $this->render("JustsyBaseBundle:AppCenter:h5bundle.html.twig", array('appid' => $appid, 'openid' => $openid, 'ssomodule' => "OAuth2"));
     }
     $ldap_uid = $bindinfo["bind_uid"];
     $cacheKey = md5($appid . $openid);
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $this->container);
     if (empty($data)) {
         $this->get("logger")->err("{$appid}.{$openid}");
         $resp = new Response("太长时间未操作,请重新进入应用");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $data = json_decode($data, true);
     $acctoken = $data["access_token"];
     //$this->get("logger")->err($acctoken);
     //获取authkey
     $url = "http://openapi.exmail.qq.com:12211/openapi/mail/authkey";
     $authkey = Utils::do_post_request($url, "alias=" . $ldap_uid . "&access_token=" . $acctoken);
     //$this->get("logger")->err($url."?"."alias=".$ldap_uid."&access_token=".$acctoken);
     //$this->get("logger")->err($authkey);
     if (empty($authkey)) {
         $resp = new Response("腾讯企业邮箱登录失败");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = json_decode($authkey, true);
     if (!isset($authkey["auth_key"])) {
         if ($authkey["error"] == "invalid_token") {
             Cache_Enterprise::delete(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $this->container);
             $resp = new Response("腾讯企业邮箱登录失败:<br>token无效或已经过期,请稍后重试!");
         } else {
             $resp = new Response("腾讯企业邮箱登录失败:<br>" . json_encode($authkey));
         }
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = $authkey["auth_key"];
     $login_url = "https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=" . $agent . "&user="******"&ticket=" . $authkey;
     //$this->get("logger")->err($login_url);
     return Utils::http_redirect($login_url);
 }