public function ResetPassWordAction() { $da = $this->get("we_data_access"); $da_im = $this->get("we_data_access_im"); $request = $this->getRequest(); $account = strtolower($request->get("account")); $password = $request->get("password"); $result = array("success" => true, "message" => ""); $user = $this->get('security.context')->getToken()->getUser(); try { $u_staff = new Staff($da, $da_im, $account, $this->get('logger'), $this->container); $targetStaffInfo = $u_staff->getInfo(); $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $this->get('security.encoder_factory')); if ($re) { //$this->get("logger")->err("sendImPresence:".$targetStaffInfo["fafa_jid"]); //给自己发送一个staff-changepasswod的出席,通知在线客户端密码发生修改,需要新密码重新登录 Utils::sendImPresence($user->fafa_jid, $targetStaffInfo["fafa_jid"], "staff-changepasswod", "staff-changepasswod", $this->container, "", "", false, Utils::$systemmessage_code); //记录用户操作日志 $syslog = new \Justsy\AdminAppBundle\Controller\SysLogController(); $syslog->setContainer($this->container); $desc = "重置了用户账号:" . $account . "登录密码!"; $syslog->AddSysLog($desc, "重置密码"); } else { $result = array("success" => false, "message" => "修改密码错误!"); } } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); $result = array("success" => false, "message" => "修改密码错误!"); } $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function commit($parameters) { if (empty($parameters)) { $result = Utils::WrapResultError("无效的数据"); return $result; } $currUser = $parameters["user"]; if (empty($currUser)) { return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN); } $audit_staffs = $parameters["audit_staffs"]; //审批人。多个审批人使用;分隔 if (empty($audit_staffs)) { return Utils::WrapResultError("审批人不能为空"); } $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container); try { $content = $currUser->nick_name . "申请请假" . $parameters["days"] . "天"; //创建新流程 $result = $wfl->createWorkflow(array("appid" => $parameters["appid"], "user" => $currUser, "to" => $audit_staffs, "wf_name" => "请假申请", "wf_content" => $content, "wf_type" => $wf_type, "attachment" => $parameters["attachment"])); if (!empty($result)) { try { //写业务表 $apply_id = SysSeq::GetSeqNextValue($this->conn, "we_app_apply_leave", "id"); $sql = "insert into we_app_apply_leave(id,wf_id,leavetype,start_date,end_date,days,reason,create_datetime,staff,eno,appid)values(?,?,?,?,?,?,?,now(),?,?,?)"; $this->conn->ExecSQL($sql, array((string) $apply_id, (string) $result["wf_id"], (string) $parameters["leavetype"], (string) $parameters["start_date"], (string) $parameters["end_date"], (double) $parameters["days"], (string) $parameters["reason"], (string) $currUser->getUserName(), (string) $currUser->eno, (string) $parameters["appid"])); } catch (\Exception $e) { $wfl->removeWorkflow(array("wf_id" => $result["wf_id"])); throw new \Exception($e); } //获取审批人的jid $to = explode(";", $audit_staffs); $tojids = array(); for ($i = 0; $i < count($to); $i++) { $staff = new Staff($this->conn, $this->conn_im, $to[$i], $this->logger, $this->container); $staffdata = $staff->getInfo(); if (empty($staffdata)) { continue; } $tojids[] = $staffdata["fafa_jid"]; } //向审批人发送消息 Utils::sendImMessage("", $tojids, "bus_apply", json_encode($re), $this->container, "", "", false, '', '0'); } return $result; } catch (\Exception $e) { $this->logger->err($e); $result = Utils::WrapResultError($e->getMessage()); } return $result; }
public function saveAction() { $reslt = array(); $request = $this->get("request"); $uid = isset($_SESSION["uid"]) ? $_SESSION["uid"] : ""; if (empty($uid)) { $reslt["s"] = "0"; $reslt["msg"] = "微博登录失败或超时,请重新通过微博登录!"; $response = new Response(json_encode($reslt)); $response->headers->set('Content-Type', 'text/json'); return $response; } $type = $request->get("bind_type"); $login_account = $request->get("login_account"); $pwd = $request->get("pwd"); try { //校验wefafa帐号和密码 $staffMgr = new Staff($this->get('we_data_access'), null, $login_account, $this->get('logger')); $staffInfo = $staffMgr->getInfo(); if (empty($staffInfo)) { $reslt["s"] = "0"; $reslt["msg"] = "帐号[" . $login_account . "]不存在!"; } else { $tcode = $staffInfo["t_code"]; $p_code = DES::encrypt($pwd); if ($tcode != $p_code) { $reslt["s"] = "0"; $reslt["msg"] = "帐号或密码不正确!"; } else { $accountbind = new \Justsy\BaseBundle\Management\StaffAccountBind($this->get('we_data_access'), null, $this->get('logger')); $r = $accountbind->Bind($type, "", $login_account, $uid); $this->get('logger')->err($type . "," . $uid . "," . $login_account . "," . $uid); $reslt["s"] = $r; } } } catch (\Exception $e) { $this->get('logger')->err($e); $reslt["s"] = "0"; $reslt["msg"] = "绑定失败,请检查帐号是否填写正确!"; } $response = new Response(json_encode($reslt)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function n($parameters) { if (is_string($parameters)) { $parameters = explode("\\", $parameters); } if (count($parameters) == 0) { return Utils::WrapResultError("无效的login_account参数"); } $login_account = $parameters[0]; if (empty($login_account)) { return Utils::WrapResultError("无效的login_account参数"); } $staffMgr = new Staff($this->conn, $this->conn_im, $login_account, $this->logger, $this->container); $staffdata = $staffMgr->getInfo(); if (empty($staffdata)) { return Utils::WrapResultError("未查找到人员信息"); } return Utils::WrapResultOK(array('code' => 'n', 'data' => $staffdata)); }
private function checkOpenid($db, $openid) { $staffinfo = new Staff($db, $this->get("we_data_access_im"), $openid, $this->get("logger"), $this->container); $obj = $staffinfo->getInfo(); return empty($obj) ? false : $obj; }
public function revokeMsgAction() { //判断请求域。是wefafa或子域则不验证授权令牌 $isWeFaFaDomain = $this->checkWWWDomain(); $request = $this->get("request"); $da = $this->get("we_data_access"); if (!$isWeFaFaDomain) { $token = $this->checkAccessToken($request, $da); if (!$token) { return $this->responseJson($request, Utils::WrapResultError('参数Appid或Openid或Access_token未指定或无效.')); } } $openid = $request->get("openid"); $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $result = Utils::WrapResultError("无效操作帐号"); return $this->responseJson($request, $result); } $to_jid = array(); $chatjid = $request->get('jid'); $to_jid[] = $chatjid; $groupid = $request->get('groupid'); $msgid = $request->get('msgid'); if (empty($chatjid) && empty($groupid)) { return $this->responseJson($request, Utils::WrapResultError('无效的撤回类型.')); } if (empty($msgid)) { return $this->responseJson($request, Utils::WrapResultError('无效的消息ID.')); } if (!empty($groupid)) { $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($da, $this->get("we_data_access_im"), $this->container); $to_jid = $groupMgr->getGroupMembersJidByIM($groupid); //群消息默认采用的发送时的iq ID。生成规则:Msgid =case QMsgid of []-> From#jid.luser++"-"++IQId; _-> QMsgid end, //生成消息ID $jid_user = explode('@', $staffdata['jid'])[0]; $msgid = $jid_user . '-' . $msgid; } $msgtype = !empty($chatjid) ? 'chat' : 'group'; $notice = array(); $message = json_encode(Utils::WrapMessage('message_revoke', array('type' => $msgtype, 'msgid' => $msgid, 'sender' => array('nick_name' => $staffdata['nick_name'], 'photo' => $staffdata['photo_path'], 'jid' => $staffdata['jid'], 'sendtime' => date("Y-m-d H:i:s", time()))), $notice)); $success = Utils::sendImMessage($staffdata['jid'], $to_jid, "message_revoke", $message, $this->container, "", "", false, Utils::$systemmessage_code); return $this->responseJson($request, Utils::WrapResultOK('')); }
public function push_receiverlistAction() { $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $request = $this->getRequest(); //访问权限校验 $api = new \Justsy\OpenAPIBundle\Controller\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 $this->responseJson($request, $re); } } $openid = $request->get("openid"); $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $result = Utils::WrapResultError("无效操作帐号"); return $this->responseJson($request, $result); } $appid = $request->get('appid'); $appmgr = new \Justsy\BaseBundle\Management\App($this->container); $appdata = $appmgr->getappinfo(array('appid' => $appid)); if (empty($appdata)) { $result = Utils::WrapResultError("无效应用标识"); return $this->responseJson($request, $result); } $data = $request->get("data"); //部门名称 if (empty($data)) { $result = Utils::WrapResultError("无效的数据"); return $this->responseJson($request, $result); } $data = json_decode($data, true); $noticeMgr = new \Justsy\BaseBundle\Management\PromptlyNotice($this->container, $staffdata, $appdata); $result = $noticeMgr->getReceiverList($data); return $this->responseJson($request, $result); }
public function removeMonitorAction() { $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 $this->responseJson($request, $re); } } $openid = $request->get("openid"); $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $result = Utils::WrapResultError("无效操作帐号"); return $this->responseJson($request, $result); } $to = $request->get("to"); if (empty($to)) { $result = Utils::WrapResultError("无效的帐号"); return $this->responseJson($request, $result); } $to = $staffinfo->getStaffInfo($to); if (empty($to)) { $result = Utils::WrapResultError("无效的帐号"); return $this->responseJson($request, $result); } try { $sql = 'delete from t_module_location_monitor where staff=?'; $da->ExecSQL($sql, array((string) $to['jid'])); $sql = 'delete from t_module_location where staff=?'; $da->ExecSQL($sql, array((string) $to['login_account'])); } catch (\Exception $e) { } $senddata = array('opt' => 'stop'); $msg = Utils::WrapMessage('sendlocation', $senddata, array()); //$msgxml = Utils::WrapMessageXml($this->module["jid"],$msg,'sendlocation-id'); $api->sendMsg("", $to['jid'], 'sendlocation', json_encode($msg)); return $this->responseJson($request, Utils::WrapResultOk("")); }
public function listAction() { $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $request = $this->getRequest(); //访问权限校验 $api = new \Justsy\OpenAPIBundle\Controller\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 $this->responseJson($request, $re); } } $openid = $request->get("openid"); $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $result = Utils::WrapResultError("无效操作帐号"); return $this->responseJson($request, $result); } $verCrl = new \Justsy\AdminAppBundle\Controller\VersionController(); $verCrl->setContainer($this->container); return $this->responseJson($request, $verCrl->SearchVersionAction()); }
public function getatten_staff_setup($paramObj) { $staff = $paramObj['staff']; $user = $paramObj['user']; $eno = $user->eno; $sql = 'select * from ma_checkatten_setup where object_id=? and eno=? and object_type=3 and setup_statu=1'; $ds = $this->conn->GetData('t', $sql, array((string) $staff, (string) $user->eno)); if (count($ds['t']['rows']) == 0) { $staffMgr = new Staff($this->conn, $this->conn_im, $staff, $this->logger, $this->container); $data = $staffMgr->getInfo(); $paramObj['deptid'] = $data['dept_id']; return $this->getatten_dept_setup($paramObj); } return Utils::WrapResultOK($ds['t']['rows']); }
public function getLoginAppendData(&$re, $login_account, $portalversion, $comefrom, $db, $db_im, $clientdatetime) { $we_sys_param = $this->container->get('we_sys_param'); $imserver = $we_sys_param->GetSysParam("imserver"); if (empty($imserver)) { $imserver = "localhost:5222"; } $re["imserver"] = $imserver; $url = $this->container->getParameter('FILE_WEBSERVER_URL'); $url = str_replace("/getfile/", "", $url) . "/api/http/version/check"; $re["imupdateserver"] = $url; if (!empty($clientdatetime)) { $sys = new \Justsy\InterfaceBundle\Controller\SystemController(); $sys->setContainer($this->container); $re["server_time"] = $sys->getMillisecond($clientdatetime); } else { $re["server_time"] = 0; } //$re["publicuser"] = "******"; //是否是公共用户(未加入企业用户) //$re["micro_app_jid"] = ""; $re["info"] = array(); //$re["rosters"] = array(); //$re["portalconfig_version"] = ""; //$re["portalconfig_xml"] = ""; //获取个人信息 $staffinfo = new Staff($db, $db_im, $login_account, $this->get("logger"), $this->container); $result = $staffinfo->getInfo(); if (!empty($result)) { $returnAttrs = explode(",", "jid,login_account,nick_name,photo_path,dept_id,dept_name,eno,ename,self_desc,duty,sex_id,mobile_bind,birthday"); for ($i = 0; $i < count($returnAttrs); $i++) { $key = $returnAttrs[$i]; $re["info"][$key] = $result[$key]; } //为了避免用户修改密码后只刷新了所在服务器,im密码实时获取 //$sql = "select password from users where username=?"; //$iminfo = $db_im->GetData("im",$sql,array((string)$re["jid"])); //$re["des"] =count($iminfo["im"]["rows"])>0 ? $iminfo["im"]["rows"][0]["password"] : ""; } return $re; }
public function register_announcer($parameter) { $nick_name = isset($parameter["name"]) ? $parameter["name"] : null; $state = isset($parameter["state"]) ? $parameter["state"] : "add"; $login_account = isset($parameter["login_account"]) ? $parameter["login_account"] : null; $account = explode("@", $login_account); $ldap_uid = $account[0]; $deptid = isset($parameter["deptid"]) ? $parameter["deptid"] : array(); $fileid = isset($parameter["fileid"]) ? $parameter["fileid"] : null; $fileid = empty($fileid) ? null : $fileid; $password = isset($parameter["password"]) ? $parameter["password"] : null; $staffid = isset($parameter["staffid"]) ? $parameter["staffid"] : array(); $user = $parameter["user"]; $success = true; $msg = ""; $da = $this->conn; if ($state == "add") { //取公众号部门id $departmentid = ""; $sql = " select dept_id from we_department where fafa_deptid=?;"; $ds = $da->GetData("table", $sql, array("v" . $user->eno . "999888")); if ($ds && $ds["table"]["recordcount"] > 0) { $departmentid = $ds["table"]["rows"][0]["dept_id"]; $register = new \Justsy\BaseBundle\Controller\ActiveController(); $register->setContainer($this->container); $register_parameter = array("account" => $login_account, "realName" => $nick_name, "passWord" => $password, "ldap_uid" => $ldap_uid, "eno" => $user->eno, "ename" => $user->ename, "isNew" => '0', "mailtype" => "1", "import" => '1', "isSendMessage" => "N", "mobile" => "", "duty" => "", "indefaultgroup" => "N", "mutual" => "N", "deptid" => $departmentid); $success = $register->doSave($register_parameter); } if ($success) { //向广播员添加具有的默认菜单项 $sql = "insert into mb_staff_menu(staff_id,menu_id)values(?,'firendcircle');"; try { $da->ExecSQL($sql, array((string) $login_account)); } catch (\Exception $e) { } } if (!$success) { $msg = "用户账号(" . $login_account . ")注册失败!"; } } else { //用户修改了密码的操作 if (!empty($password)) { $u_staff = new Staff($da, $this->conn_im, $login_account, $this->logger); $targetStaffInfo = $u_staff->getInfo(); $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $this->container->get('security.encoder_factory')); $this->logger("-----------" . $re); } } if ($success) { $sqls = array(); $paras = array(); //修改头像 $sql = "update we_staff set nick_name=?,photo_path=?,photo_path_small=?,photo_path_big=? where login_account=?;"; $para = array((string) $nick_name, (string) $fileid, (string) $fileid, (string) $fileid, (string) $login_account); array_push($sqls, $sql); array_push($paras, $para); //修改im数据 //获得fafa_jid $fafa_jid = ""; $sql = "select fafa_jid from we_staff where login_account=?;"; $ds = $da->GetData("table", $sql, array((string) $login_account)); if ($ds && $ds["table"]["recordcount"] > 0) { $fafa_jid = $ds["table"]["rows"][0]["fafa_jid"]; $sql_im = "update im_employee set employeename=?,photo=? where loginname=?;"; $para_im = array((string) $nick_name, $fileid, (string) $fafa_jid); try { $this->conn_im->ExecSQL($sql_im, $para_im); } catch (\Exception $e) { } } if ($state == "edit") { $sql = "delete from we_announcer where login_account=?;"; $da->ExecSQL($sql, array((string) $login_account)); } //部门的处理 for ($j = 0; $j < count($deptid); $j++) { $sql = "insert into we_announcer(login_account,objid,`type`)values(?,?,1)"; $para = array((string) $login_account, (string) $deptid[$j]); array_push($sqls, $sql); array_push($paras, $para); } //人员的处理 for ($j = 0; $j < count($staffid); $j++) { $sql = "insert into we_announcer(login_account,objid,`type`)values(?,?,2)"; $para = array((string) $login_account, (string) $staffid[$j]); array_push($sqls, $sql); array_push($paras, $para); } try { $da->ExecSQLS($sqls, $paras); } catch (\Exception $e) { $success = false; $msg = "更新用户信息失败!"; $this->logger->err($e->getMessage()); } } return array("success" => $success, "msg" => $msg); }
public function setFriendByDept($deptid, $user = null) { //判断部门是否设置了自动好友 $deptinfo = $this->getInfo($deptid); if ($deptinfo['friend'] != '1') { return; } $da = $this->conn_im; $friendLst = array(); $success = true; $msg = ""; if (!empty($user)) { $login_account = $user["login_account"]; $fafa_jid = array(isset($user["fafa_jid"]) ? $user["fafa_jid"] : null); $staffMgr = new Staff($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container); if (empty($fafa_jid)) { $user = $staffMgr->getInfo(); } $friendLst = array(array("jid" => $user["fafa_jid"], "nick_name" => $user["nick_name"])); } else { $domain = $this->container->getParameter('edomain'); $staffMgr = new Staff($this->conn, $this->conn_im, "admin@" . $domain, $this->container->get("logger"), $this->container); $sql = 'SELECT a.loginname jid,a.employeename nick_name FROM im_employee a where a.deptid=? and not exists(select jid from rosterdept where deptid=? and a.loginname=jid)'; $ds = $da->GetData("t", $sql, array((string) $deptid, (string) $deptid)); $friendLst = $ds["t"]["rows"]; } $to_jid = array(); $staffcount = count($friendLst); if ($staffcount == 0) { return array("success" => false, "message" => '该部门下没有人员,请进入子部门进行设置'); } for ($i = 0; $i < $staffcount; $i++) { $fafa_jid = $friendLst[$i]["jid"]; $nick_name = $friendLst[$i]["nick_name"]; //判断是否已全部成为好友 $sql = "SELECT a.loginname jid,a.employeename nick_name FROM im_employee a where a.deptid=? and not exists (select jid from rosterusers b where a.loginname=b.jid and b.username=? and b.subscription='B')"; try { $ds_member = $da->GetData("member", $sql, array((string) $deptid, (string) $fafa_jid)); if ($ds_member && count($ds_member["member"]["rows"] > 0)) { if (!empty($user)) { //如果是指定人员与部门人员成为好友,通知对象为部门中还未不是该人的帐号jid for ($ic = 0; $ic < count($ds_member["member"]["rows"]); $ic++) { array_push($to_jid, $ds_member["member"]["rows"][$ic]["jid"]); } } $state = $staffMgr->DeptAddFriend($this->container, $deptid, $fafa_jid, $nick_name, $ds_member["member"]["rows"]); } } catch (\Exception $e) { $success = false; $msg = "设置部门人员互为好友出错!"; $this->container->get("logger")->err($e->getMessage()); return array("success" => $success, "message" => $msg); } } $to_jid = $this->getStaffJid($deptid); if (count($to_jid) > 0) { //获取在线帐号 Utils::findonlinejid($da, $to_jid); //向成员发送出席 $message = array('deptid' => $deptid); $msg = json_encode(Utils::WrapMessage('dept_friend', $message, array())); Utils::sendImPresence($fafa_jid, $to_jid, "dept_friend", $msg, $this->container, "", "", false, '', '0'); } return array("success" => $success, "message" => $msg); }
public function delete_service($parameter) { $micro_id = $parameter["micro_id"]; $login_account = $parameter["login_account"]; $user = $parameter["user"]; $MicroAccountMgr = new Staff($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container); $data = $MicroAccountMgr->getInfo(); if (empty($data)) { return array("success" => false); } $MicroAccountMgr = new MicroAccountMgr($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container); $dataexec = $MicroAccountMgr->removeByID($micro_id); $success = true; if ($dataexec === false) { $success = false; } else { $sqls = array(); $paras = array(); $sqls[] = "delete from im_microaccount_msg where microaccount=?"; $paras[] = array((string) $data["fafa_jid"]); $sqls[] = "delete from im_microaccount_memebr where microaccount=?"; $paras[] = array((string) $data["fafa_jid"]); $this->conn_im->ExecSQLS($sqls, $paras); $sql = "delete from we_service where login_account=?;"; try { $this->conn->ExecSQL($sql, array((string) $login_account)); } catch (\Exception $e) { $this->container->get("logger")->err($e->getMessage()); return Utils::WrapResultError($e->getMessage()); } } return Utils::WrapResultOK(""); }
public static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom) { $login_account = strtolower($login_account); try { $password = strtoupper(md5($password)); //$container->get("logger")->err($password); $staff = new Staff($dbcon, $con_im, strtolower($login_account)); $user = $staff->getInfo(); if ($user == null || $user["state_id"] != "1") { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; return $re; } $login_account = $user["login_account"]; $Obj = new \Justsy\BaseBundle\Login\UserProvider($container); // $factory = $container->get('security.encoder_factory'); //判断是否修改过密码.这时针对从第三方注册的帐号的密码为不可解开密文的情况时,sns中的密码和t_code字段临时存储为完全相同的数据 //程序判断到这种情况 时,需要进行内部自动更改密码操作,之前的临时数据即为用户新密码 //$container->get("logger")->err($user["password"]."==".$user["t_code"]); if ($user["password"] == $user["t_code"]) { $tmpPass = DES::encrypt($password); if ($tmpPass != $user["t_code"]) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } //更新密码 $staff->changepassword($login_account, $password, $factory); } $user = new UserSession($login_account, $password, $login_account, array("ROLE_USER")); $encoder = $factory->getEncoder($user); $password_enc = $encoder->encodePassword($password, $login_account); $user = $Obj->loadUserByUsername($login_account, $comefrom); //$container->get("logger")->err($user->getPassword()."==".$password_enc); $logined = 1; if ($user->getPassword() != $password_enc) { //如果密码不正确时,有可能是修改了密码,只刷新了一台服务器上的缓存,其他集群环境中的还是原来的缓存 //刷新当前服务器的人员信息才重试 $u_staff = new Staff($dbcon, $con_im, $user->getusername(), $container->get('logger')); $user = $u_staff->getInfo(true); //刷新人员信息 //$container->get("logger")->err("refresh cache data....."); $user = $Obj->loadUserByUsername($login_account, $comefrom); if ($user->getPassword() != $password_enc) { $container->get("logger")->err($login_account . "==>" . $password . "=>" . $password_enc . "=>" . $user->getPassword()); $re["returncode"] = ReturnCode::$ERROFUSERORPWD; $logined = null; } } if (!empty($logined)) { //�Ǽ�seesion $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles()); $container->get("security.context")->setToken($token); $session = $request->getSession()->set('_security_' . 'secured_area', serialize($token)); $event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($request, $token); $container->get("event_dispatcher")->dispatch("security.interactive_login", $event); $re["returncode"] = ReturnCode::$SUCCESS; $re["openid"] = $user->openid; $re["login_account"] = $login_account; $re["ldap_uid"] = $user->ldap_uid; $re["jid"] = $user->fafa_jid; $re["des"] = $user->t_code; } } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } catch (\Exception $e) { $container->get("logger")->err($e); $re["returncode"] = ReturnCode::$SYSERROR; } return $re; }
public function saveselfdescAction() { $res = $this->get("request"); $auth = $res->get("authcode"); $openid = $res->get("p"); $desc = $res->get("desc"); if ($auth == null || $auth == "") { $response = new Response("{\"s\":0,\"msg\":\"authcode is null\"}"); return $response; } try { $auth = trim(DES::decrypt($auth)); //解密参数串 $openid = trim(DES::decrypt($openid)); $desc = trim(DES::decrypt($desc)); //授权码已过期 $lng = time() - (int) $auth; if ($lng > 30 || $lng < 0) { $response = new Response("{\"s\":0,\"msg\":\"authcode date out!\"}"); return $response; } if (empty($openid)) { $response = new Response("{\"s\":0,\"msg\":\"openid is null\"}"); return $response; } $sql = "update we_staff set self_desc=? where openid=?"; $da = $this->get("we_data_access"); $da->ExecSQL($sql, array((string) $desc, (string) $openid)); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, null, $openid, $this->get('logger')); $staffinfo = $staffMgr->getInfo(); if ($staffinfo != null) { $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($da, $this->get('logger'), $this->container); $friendevent->signchange($staffinfo["login_account"], $staffinfo["nick_name"], $desc); } //$this->get('session')->migrate(); $response = new Response("{\"s\":1,\"msg\":\"\"}"); return $response; } catch (\Exception $e) { $this->get("logger")->err($e); $response = new Response("{\"s\":0,\"msg\":\"exception\"}"); return $response; } }
public function importActiveSaveAction() { $request = $this->get("request"); $account = trim($request->get("account")); $passWord = trim($request->get("passWord")); if (empty($account) || empty($passWord)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => "帐号或者密码不能为空")); } $staffmgr = new Staff($this->get("we_data_access"), $this->get("we_data_access_im"), $account); $isexist = $staffmgr->isExist(); if ($isexist != null) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => "帐号已可以正常使用")); } try { $importData = $staffmgr->getImportInfo(); ////判断帐号、姓名、手机是否重复或已使用 $arrayName = array((string) $importData["login_account"], (string) $importData["eno"], (string) $importData["nick_name"]); $sql = "select (select nick_name from we_staff where login_account=?) accountcheck ,"; $sql = $sql . " (select nick_name from we_staff where eno=? and nick_name=?) namecheck "; $mobileNO = trim($importData["mobile"]); if (!empty($mobileNO)) { $sql = $sql . " ,(select nick_name from we_staff where mobile=?) mobilecheck "; $arrayName[] = (string) $mobileNO; } $da = $this->get("we_data_access"); $ds = $da->getdata("t", $sql, $arrayName); if ($ds) { $dr = $ds["t"]["rows"][0]; if (!empty($dr["accountcheck"])) { if ($dr["accountcheck"] == $importData["nick_name"]) { throw new \Exception("您的帐号的已激活,可以正常使用。"); } else { throw new \Exception("该帐号已被" . $dr["accountcheck"] . "使用!"); } } else { if (!empty($dr["namecheck"])) { throw new \Exception("姓名已存在,不能重复激活!"); } else { if (!empty($dr["mobilecheck"])) { throw new \Exception("手机号已被" . $dr["mobilecheck"] . "使用,请使用其他有效手机号码注册!"); } } } } //激活人员帐号 $sdo = new \Justsy\BaseBundle\Controller\ActiveController(); $sdo->setContainer($this->container); $sdo->doSaveAction(); //根据导入信息更新注册信息 $staffmgr->updateByImport($importData); $staffmgr->deleteImportPhy(); } catch (\Exception $e) { $this->get("logger")->err($e); return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => $e->getMessage())); } $data = $staffmgr->getInfo(); $data["t_code"] = substr($passWord, 0, 1) . "******" . substr($passWord, -1); $data["password"] = $passWord; return $this->render('JustsyBaseBundle:Active:import_succeed.html.twig', array('edomain' => $data["eno"], 'data' => $data)); }
public function executeAction() { $request = $this->getRequest(); $login_account = $request->get("login_account"); $fafa_jid = $request->get("fafa_jid"); $type = $request->get("type"); $password = $request->get("password"); $my_jid = $this->get('security.context')->getToken()->getUser()->fafa_jid; $result = array(); $send_status = false; $msg = ""; //修改密码 if ($type == "adminLock") { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger')); $targetStaffInfo = $u_staff->getInfo(); $re = $u_staff->changepassword($login_account, $password, $this->get('security.encoder_factory')); if ($re) { $send_status = Utils::sendImMessage($my_jid, $fafa_jid, $type, $password, $this->container, "", "", false, Utils::$systemmessage_code, '0'); } else { $msg = "密码修改失败!"; } } else { $send_status = Utils::sendImMessage($my_jid, $fafa_jid, $type, $type, $this->container, "", "", false, Utils::$systemmessage_code, '0'); } $result = array("success" => $send_status, "msg" => $msg); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }
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)); }
public static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom) { $defaultPostURl = "http://10.100.20.27/CallCenter/ESB_InvokeService.ashx"; $cacheobj = new Enterprise($dbcon, $container->get("logger"), $container); // $authConfig = $cacheobj->getUserAuth(); $httpUrlConfig = $authConfig["ssoauthurl"]; if (empty($httpUrlConfig)) { $httpUrlConfig = $defaultPostURl; $eno = "100001"; } else { $ldapConfgiObject = json_decode($httpUrlConfig, true); $eno = $ldapConfgiObject["ENO"]; $httpUrlConfig = $ldapConfgiObject["URL"]; } try { $data = array(); $data["loginName"] = $login_account; $data["password"] = $password; $data["isNeedSyn"] = false; $para = "ServiceName=WXSC_Account&MethodName=POST:JSON:UserAuthentication&Message=" . json_encode($data) . "&Version=1"; $container->get("logger")->err("SOA URL:" . $httpUrlConfig . "?" . $para); $postresult = Utils::do_post_request($httpUrlConfig, $para); $container->get("logger")->err("SOA Result:" . $postresult); $resultObject = json_decode($postresult, true); if (!empty($resultObject["errcode"]) || $resultObject["isSuccess"] === false) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; return $re; } $mbuser = $resultObject["results"]; $fafa_account = strtolower($login_account . "@fafatime.com"); if (count($mbuser) > 0) { $mbuser = $mbuser[0]; $nickName = isset($mbuser["nickName"]) ? $mbuser["nickName"] : $mbuser["phoneNumber"]; $staff = new Staff($dbcon, $con_im, $fafa_account); $staffinfo = $staff->getInfo(); if (empty($staffinfo)) { //新用户:注册 激活 $enInfo = $cacheobj->getInfo($eno); $active = new \Justsy\BaseBundle\Controller\ActiveController(); $active->setContainer($container); $uid = strtolower($mbuser["id"]); $active->doSave(array('account' => $fafa_account, 'realName' => $nickName, 'passWord' => $password, 'eno' => $eno, 'ename' => $enInfo["ename"], 'isNew' => '0', 'mailtype' => "1", 'isSendMessage' => "N", 'import' => '1')); $sex_id = "1"; $duty = isset($mbuser["userRoles"]) ? $mbuser["userRoles"] : ""; $ldap_uid = isset($mbuse["id"]) ? $mbuser["id"] : ""; $tmp = ""; if (!empty($duty) && count($duty) > 0) { for ($i = 0; $i < count($duty); $i++) { $tmp = $duty[$i]["roleName"]; if ($tmp == "Designer") { break; } } } if ($tmp == "Designer") { $duty = "造型师"; } else { $duty = ""; } $sql = "update we_staff set ldap_uid=?,sex_id=?,duty=? where login_account=?"; $params = array($uid, (string) $sex_id, $duty, $fafa_account); $dbcon->ExecSQL($sql, $params); if (!empty($mbuser["phoneNumber"])) { $staff->checkAndUpdate(null, $mbuser["phoneNumber"], null, null); } } else { $duty = isset($mbuser["userRoles"]) ? $mbuser["userRoles"] : ""; $ldap_uid = isset($mbuser["id"]) ? $mbuser["id"] : ""; $tmp = ""; if (!empty($duty) && count($duty) > 0) { for ($i = 0; $i < count($duty); $i++) { $tmp = $duty[$i]["roleName"]; if ($tmp == "Designer") { break; } } } if ($tmp == "Designer") { $duty = "造型师"; } else { $duty = ""; } //更新信息 $staff->checkAndUpdate($nickName, $mbuser["phoneNumber"], null, $duty, $ldap_uid); } //头像 $headUrl = $mbuser["headPortrait"]; } $Obj = new \Justsy\BaseBundle\Login\UserProvider($container); $user = $Obj->loadUserByUsername($fafa_account, $comefrom); //�Ǽ�seesion $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles()); $container->get("security.context")->setToken($token); $session = $request->getSession()->set('_security_' . 'secured_area', serialize($token)); $event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($request, $token); $container->get("event_dispatcher")->dispatch("security.interactive_login", $event); $re["returncode"] = ReturnCode::$SUCCESS; $re["openid"] = $user->openid; $re["login_account"] = $fafa_account; $re["ldap_uid"] = $user->ldap_uid; $re["jid"] = $user->fafa_jid; //为了避免用户修改密码后只刷新了所在服务器,im密码实时获取 $sql = "select password from users where username=?"; $iminfo = $con_im->GetData("im", $sql, array((string) $user->fafa_jid)); $re["des"] = count($iminfo["im"]["rows"]) > 0 ? $iminfo["im"]["rows"][0]["password"] : ""; } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; } return $re; }
public function updateStaffAction() { $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $request = $this->getRequest(); $state = $request->get("state"); $im_deptid = $request->get("dept_id"); //将im的部门id转化为sns里的部门id $deptInfo = $this->getDeptInfo($im_deptid); $sns_deptid = $deptInfo["deptid"]; $login_account = $request->get("login_account"); $e_mail = $request->get("e_mail"); $nick_name = $request->get("nick_name"); $password = $request->get("password"); $sex = $request->get("sex"); $duty = $request->get("duty"); $duty = empty($duty) ? null : $duty; $mobile = $request->get("mobile"); $mobile = empty($mobile) ? null : $mobile; $success = true; $msg = ""; //判断手机号正误 if (!empty($mobile)) { if (!Utils::validateMobile($mobile)) { $result = array("success" => false, "msg" => "手机账号格式错误!"); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } else { $sql = ""; $para = array(); if ($state == "add") { $sql = "select count(*) number from we_staff where mobile_bind=?;"; array_push($para, (string) $mobile); } else { $sql = "select count(*) number from we_staff where mobile_bind=? and login_account!=?;"; array_push($para, (string) $mobile, $login_account); } try { $ds = $da->GetData("table", $sql, $para); if ($ds && $ds["table"]["recordcount"] > 0) { if ((int) $ds["table"]["rows"][0]["number"] > 0) { $result = array("success" => false, "msg" => "已存在该手机号码!"); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } } } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); } } } $user = $this->get('security.context')->getToken()->getUser(); $deptMgr = new \Justsy\BaseBundle\Management\Dept($da, $da_im, $this->container); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->container->get("logger"), $this->container); if ($state == "add") { if ($staffMgr->checkUser($mobile)) { $result = array("success" => false, "msg" => "用户账号已存在,请重新输入!"); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } //获得ldap_uid $login_array = explode("@", $login_account); if (count($login_array) < 2) { continue; } $ldap_uid = $login_array[0]; //注册用户账号 $register = new \Justsy\BaseBundle\Controller\ActiveController(); $register->setContainer($this->container); $parameter = array("account" => $login_account, "realName" => $nick_name, "passWord" => $password, "ldap_uid" => $ldap_uid, "eno" => $user->eno, "ename" => $user->ename, "isNew" => '0', "mailtype" => "1", "import" => '1', "isSendMessage" => "N", "mobile" => $mobile, "duty" => $duty, "deptid" => $sns_deptid, "mutual" => "Y"); $result = $register->doSave($parameter); if ($result["returncode"] == "0000") { $staffdata = $staffMgr->getInfo(); //成功后统计人员 $sql = "call dept_emp_stat(?)"; $da_im->ExecSQL($sql, array((string) $staffdata["fafa_jid"])); //自动关注服务号 $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container); $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account); $servicerMgr->atten_service($parameter); $revJids = $staffMgr->getFriendAndColleagueJid(); Utils::sendImMessage($user->fafa_jid, implode(",", $revJids), "newstaff", json_encode($staffMgr->getinfo()), $this->container, "", "", false, Utils::$systemmessage_code); } else { $success = false; $msg = "添加用户账号失败:" . $result["msg"]; } $result = array("success" => $success, "msg" => $msg); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } else { $staffinfo = $staffMgr->getInfo(); $deptinfo = $deptMgr->getinfo($staffinfo["dept_id"]); //判断是否更改了性别 if ($sex == $staffinfo["sex_id"]) { $sex = null; } //判断是否更改了职务 if ($duty == $staffinfo["duty"]) { $duty = null; } //判断是否更改了姓名 if ($nick_name == $staffinfo["nick_name"]) { $nick_name = null; } //判断是否更新了部门 if ($sns_deptid == $deptinfo["dept_id"]) { $sns_deptid = null; } //判断是否更新了手机 if ($mobile == $staffinfo["mobile_bind"]) { $mobile = null; } $uResult = $staffMgr->checkAndUpdate($nick_name, $mobile, $sns_deptid, $duty, null, $sex, null, $e_mail); $u_staff = null; $factory = null; //判断是否修改了密码 if (!empty($password)) { $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container); $factory = $this->get('security.encoder_factory'); $targetStaffInfo = $u_staff->getInfo(); $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $factory); if ($re) { //给自己发送一个staff-changepasswod的出席,通知在线客户端密码发生修改,需要新密码重新登录 Utils::sendImPresence($user->fafa_jid, $targetStaffInfo["fafa_jid"], "staff-changepasswod", "staff-changepasswod", $this->container, "", "", false, Utils::$systemmessage_code); } } //判断是否修改了帐号 if ($e_mail != $login_account) { //判断邮件是否存在 if (empty($u_staff)) { $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container); } if (empty($factory)) { $factory = $this->get('security.encoder_factory'); } $u_staff->changeLoginAccount($e_mail, $factory); } try { $revJids = $staffMgr->getFriendAndColleagueJid(); if ($uResult && !empty($sns_deptid)) { //部门变更时,需要通知手机端更新原部门和新部门数据 Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptinfo), $this->container, "", "", false, Utils::$systemmessage_code); Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptMgr->getinfo($sns_deptid)), $this->container, "", "", false, Utils::$systemmessage_code); $old_fafa_deptid = $deptinfo["fafa_deptid"]; $fafa_jid = $staffinfo["fafa_jid"]; //取消关注服务号 $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container); $parameter = array("eno" => $user->eno, "deptid" => $old_fafa_deptid, "login_account" => $login_account); $servicerMgr->cancel_atten($parameter); //自动关注服务号 $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account); $servicerMgr->atten_service($parameter); } } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); $success = false; $msg = "修改人员信息失败!"; } } $result = array("success" => $success, "msg" => $msg); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public static function tokenValidate($container, $token) { $request = $container->get("request"); $dbcon = $container->get("we_data_access"); $con_im = $container->get("we_data_access_im"); $rest = "/rest/validate"; $defaultPostURl = "https://sso.avicmall.com:8443"; $appcodeConfig = "fafa-app"; $appkeyConfig = "DKGHwqJ5H91noPYNYm9b8EUPQSY"; $cacheobj = new Enterprise($dbcon, $container->get("logger"), $container); // $authConfig = $cacheobj->getUserAuth(); $httpUrlConfig = $authConfig["ssoauthurl"]; if (empty($httpUrlConfig)) { $httpUrlConfig = $defaultPostURl; $eno = "100001"; } else { $ldapConfgiObject = json_decode($httpUrlConfig, true); $eno = $ldapConfgiObject["ENO"]; $httpUrlConfig = $ldapConfgiObject["URL"]; $appcodeConfig = $ldapConfgiObject["AppCode"]; $appkeyConfig = $ldapConfgiObject["AppKey"]; } $httpUrlConfig = $httpUrlConfig . $rest; try { $reqHeader = SsoAvicAuth::getHeaders($appcodeConfig, $appkeyConfig); $para = array("ticketName" => "SIAMTGT", "ticketValue" => $token); //$container->get("logger")->err("SOA URL:".$httpUrlConfig." Body:".json_encode($para)); $postresult = Utils::do_post_request($httpUrlConfig, json_encode($para), $reqHeader, $container->get("logger")); //$container->get("logger")->err("SOA Result:".$postresult); $resultObject = json_decode($postresult, true); if (!isset($resultObject["status"])) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; $re["msg"] = "服务器异常"; return $re; } if (!$resultObject["status"] || $resultObject["status"] == "false") { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; $re["msg"] = $resultObject["message"]; return $re; } $usertoken = $resultObject["ticketEntry"]["ticketValue"]; $user = $resultObject["user"]; //用户信息 $nickName = $user["cn"]; //获取姓名 $phoneNumber = $user["smart-securemobile"]; //获取手机号 $login_account = $user["uid"]; $eninfo = $cacheobj->getInfo($eno); $domain = $eninfo["edomain"]; $domain = strpos($domain, ".") === false ? "fafatime.com" : $domain; $fafa_account = strtolower($login_account . "@" . $domain); $staff = new Staff($dbcon, $con_im, $fafa_account); $staffinfo = $staff->getInfo(); if (empty($staffinfo)) { $password = rand(100000, 999999); //新用户:注册 激活 $enInfo = $cacheobj->getInfo($eno); $active = new \Justsy\BaseBundle\Controller\ActiveController(); $active->setContainer($container); $uid = strtolower($login_account); $active->doSave(array('account' => $fafa_account, 'realName' => $nickName, 'passWord' => $password, 'eno' => $eno, 'ename' => $enInfo["ename"], 'isNew' => '0', 'mailtype' => "1", 'deptid' => "100054", 'isSendMessage' => "N", 'import' => '1')); $sql = "update we_staff set ldap_uid=?,mobile=?,mobile_bind=? where login_account=?"; $params = array((string) $uid, (string) $phoneNumber, (string) $phoneNumber, (string) $fafa_account); $dbcon->ExecSQL($sql, $params); } else { $ldap_uid = $login_account; //更新信息 if ($nickName == $staffinfo["nick_name"]) { $nickName = null; } if ($phoneNumber == $staffinfo["mobile"]) { $phoneNumber = null; } if (!empty($nickName) || !empty($phoneNumber)) { try { $staff->checkAndUpdate($nickName, $phoneNumber, null, null, $ldap_uid); } catch (\Exception $e) { $container->get("logger")->err($e->getMessage()); } } } $Obj = new \Justsy\BaseBundle\Login\UserProvider($container); $user = $Obj->loadUserByUsername($fafa_account, $comefrom); //�Ǽ�seesion $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles()); $container->get("security.context")->setToken($token); $session = $request->getSession()->set('_security_' . 'secured_area', serialize($token)); $event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($request, $token); $container->get("event_dispatcher")->dispatch("security.interactive_login", $event); $re["returncode"] = ReturnCode::$SUCCESS; $re["openid"] = $user->openid; $re["login_account"] = $fafa_account; $re["ldap_uid"] = $user->ldap_uid; $re["jid"] = $user->fafa_jid; $re["token"] = $usertoken; //用户凭据 //为了避免用户修改密码后只刷新了所在服务器,im密码实时获取 $sql = "select password from users where username=?"; $iminfo = $con_im->GetData("im", $sql, array((string) $user->fafa_jid)); $re["des"] = count($iminfo["im"]["rows"]) > 0 ? $iminfo["im"]["rows"][0]["password"] : ""; } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } catch (\Exception $e) { $re["msg"] = $e->getMessage(); $re["returncode"] = ReturnCode::$SYSERROR; } return $re; }