Commit ea48a279 by v_vjyjiang

st

parent 37da0aee
var url = require("url");
var system = require("../../base/system");
var metaCtl=system.getObject("web.common.metaCtl");
var userCtl=system.getObject("web.auth.userCtl");
var metaCtl = system.getObject("web.common.metaCtl");
var userCtl = system.getObject("web.auth.userCtl");
module.exports = function (app) {
app.get("/gtb",async function(req,res){
app.get("/autologin", async function (req, res) {
res.render("autologin", {});
});
app.get("/gtb", async function (req, res) {
console.log(req.hostname);
var appinfo=await metaCtl.getAppInfo(req);
res.render("gtb",appinfo);
var appinfo = await metaCtl.getAppInfo(req);
res.render("gtb", appinfo);
});
app.get("/auth",async function(req,res){
var code=req.query.code;
var srcKey=req.query.srcKey;
var companyKey=req.query.companyKey;
var gtb=req.query.gtb;
if(!code){
if(gtb){
app.get("/auth", async function (req, res) {
var code = req.query.code;
var srcKey = req.query.srcKey;
var companyKey = req.query.companyKey;
var gtb = req.query.gtb;
if (!code) {
if (gtb) {
return res.redirect("/gtb/#/gtbhome");
}
return res.redirect("/");
}else{
} else {
await userCtl.authByCode(req);
if(!companyKey){
res.redirect("/admin?appKey="+srcKey);
}else{
res.redirect("/admin?appKey="+srcKey+"&companyKey="+companyKey);
if (!companyKey) {
res.redirect("/admin?appKey=" + srcKey);
} else {
res.redirect("/admin?appKey=" + srcKey + "&companyKey=" + companyKey);
}
}
});
app.all("/web/*", function (req, res, next) {
if (req.url.indexOf("register") > 0 ||
req.url.indexOf("findAllApps") > 0 ||
req.url.indexOf("checkLogin") > 0 ||
req.url.indexOf("findAllApps") > 0 ||
req.url.indexOf("checkLogin") > 0 ||
req.url.indexOf("login") > 0 ||
req.url.indexOf("getApiDoc") > 0 ||
req.url.indexOf("metaCtl") > 0 ||
......@@ -52,26 +55,26 @@ module.exports = function (app) {
next();
}
});
app.get("/",async function(req,res){
app.get("/", async function (req, res) {
console.log(req.hostname);
var appinfo=await metaCtl.getAppInfo(req);
res.render("index",appinfo);
var appinfo = await metaCtl.getAppInfo(req);
res.render("index", appinfo);
});
app.get("/admin",async function(req,res){
var appinfo=await metaCtl.getAppInfo(req);
res.render("admin",appinfo);
app.get("/admin", async function (req, res) {
var appinfo = await metaCtl.getAppInfo(req);
res.render("admin", appinfo);
});
app.get('/web/:gname/:qname/:method', function (req, res) {
req.codepath = req.headers["codepath"];
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
classPath=gname+"."+classPath;
var methodName = req.params["method"];
var gname = req.params["gname"];
classPath = gname + "." + classPath;
var params = [];
params.push(methodName);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = system.getObject("web." + classPath);
if (invokeObj["doexec"]) {
......@@ -84,18 +87,18 @@ module.exports = function (app) {
app.post('/web/:gname/:qname/:method', function (req, res) {
req.codepath = req.headers["codepath"];
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
var params = [];
classPath=gname+"."+classPath;
var methodName = req.params["method"];
var gname = req.params["gname"];
var params = [];
classPath = gname + "." + classPath;
var tClientIp = system.get_client_ip(req);
req.body.clientIp = tClientIp;
req.body.agent= req.headers["user-agent"];
req.body.classname=classPath;
req.body.agent = req.headers["user-agent"];
req.body.classname = classPath;
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = system.getObject("web." + classPath);
if (invokeObj["doexec"]) {
......
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<script src="/js/vue/axios.min.js"></script>
<script>
var data = JSON.stringify({ "appkey": "5ae2da88-0ced-4b7a-98ea-60d5e1ff7e2e", "companykey": "5f09cca9607e4beca8e2adef752a1641" });
var config = {
method: 'post',
url: 'https://deliver-center.gongsibao.com/autologin',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
window.open(response.data.openurl)
})
.catch(function (error) {
console.log(error);
});
</script>
</head>
<body>
hello
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment