Commit e188adb7 by 王昆

gsb

parent bbb9e050
...@@ -24,7 +24,7 @@ module.exports = (db, DataTypes) => { ...@@ -24,7 +24,7 @@ module.exports = (db, DataTypes) => {
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,sign_body
// fields: ['email'] // fields: ['email']
// }, // },
// //
......
...@@ -27,7 +27,7 @@ module.exports = function (app) { ...@@ -27,7 +27,7 @@ module.exports = function (app) {
app.all('*', function (req, res, next) { app.all('*', function (req, res, next) {
req.objs = system; req.objs = system;
res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild, xggadminsid'); res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild, bpostatsid');
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS'); res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// res.header('Access-Control-Allow-Credentials', 'true'); // res.header('Access-Control-Allow-Credentials', 'true');
if (req.method == 'OPTIONS') { if (req.method == 'OPTIONS') {
......
...@@ -5,118 +5,105 @@ var userCtl = system.getObject("web.auth.userCtl"); ...@@ -5,118 +5,105 @@ var userCtl = system.getObject("web.auth.userCtl");
const redisClient = system.getObject("util.redisClient"); const redisClient = system.getObject("util.redisClient");
module.exports = function (app) { module.exports = function (app) {
// app.all("/web/*", async function (req, res, next) { app.all("/web/*", async function (req, res, next) {
// var xggadminsid; let bpostatsid = req.headers["bpostatsid"] || "";
// var jsonUser = req.session.user; jsonUser = await redisClient.get(bpostatsid);
// // var jsonUser = null; if (jsonUser) {
// if(!jsonUser) { jsonUser = JSON.parse(jsonUser);
// xggadminsid = req.headers["xggadminsid"] || ""; }
// jsonUser = await redisClient.get(xggadminsid);
// if(jsonUser) {
// jsonUser = JSON.parse(jsonUser);
// }
// }
//
// if (req.url.indexOf("auth/userCtl/login") > 0 ||
// req.url.indexOf("uc/userCtl/login") > 0 ||
// req.url.indexOf("auth/userCtl/smsCode") > 0 ||
// req.url.indexOf("common/metaCtl/getApiDoc") > 0 ||
// req.url.indexOf("common/captchaCtl/captcha") > 0 ||
//
// req.url.indexOf("getRsConfig") > 0) {
// if (jsonUser) {
// req.loginUser = jsonUser;
// } else {
// req.loginUser = null;
// }
// return next();
// }
//
// if (!jsonUser) {
// res.end(JSON.stringify({ status: -99, msg: "no login" }));
// return;
// }
//
// if(xggadminsid) {
// redisClient.setWithEx(xggadminsid, JSON.stringify(jsonUser), 60 * 60 * 60);
// }
//
// req.loginUser = jsonUser;
// // if(req.loginUser.uctype != 3) {
// // res.end(JSON.stringify({ status: -99, msg: "no deliver user, kick off" }));
// // return;
// // }
// req.loginUser = jsonUser;
// next();
// });
app.get("/", async function (req, res) { if (req.url.indexOf("auth/userCtl/login") > 0 ||
res.render("index", { appinfo: null, app: null }); req.url.indexOf("auth/userCtl/register") > 0 ||
req.url.indexOf("getRsConfig") > 0) {
// console.log(req.hostname); if (jsonUser) {
// var appinfo=await metaCtl.getAppInfo(req); req.loginUser = jsonUser;
// if(!appinfo){ } else {
// res.render("index",{appinfo:null,app:null}); req.loginUser = null;
// }else{ }
// res.render("index",appinfo); return next();
// } }
});
app.get('/web/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
classPath = gname + "." + classPath;
var params = [];
if(req.loginUser) { if (!jsonUser) {
req.query = req.query || {}; res.end(JSON.stringify({status: -99, msg: "no login"}));
req.query.sign_body = req.loginUser.sign_body; return;
} }
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
params.push(res);
var p = null;
var invokeObj = system.getObject("web." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
console.log(req.url, "req.url...................");
console.log(r, "req###############################");
res.end(JSON.stringify(r));
});
});
app.post('/web/:gname/:qname/:method', function (req, res) { if (bpostatsid) {
var classPath = req.params["qname"]; redisClient.setWithEx(bpostatsid, JSON.stringify(jsonUser), 60 * 60 * 60);
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;
if(req.loginUser) { req.loginUser = jsonUser;
req.body.saas_id = req.loginUser.saas_id; next();
req.body.sign_body = req.loginUser.sign_body; });
}
params.push(methodName); app.get("/", async function (req, res) {
params.push(req.body); res.render("index", {appinfo: null, app: null});
params.push(req.query);
params.push(req); // console.log(req.hostname);
params.push(res); // var appinfo=await metaCtl.getAppInfo(req);
var p = null; // if(!appinfo){
var invokeObj = system.getObject("web." + classPath); // res.render("index",{appinfo:null,app:null});
if (invokeObj["doexec"]) { // }else{
p = invokeObj["doexec"].apply(invokeObj, params); // res.render("index",appinfo);
} // }
p.then(r => { });
res.end(JSON.stringify(r)); app.get('/web/:gname/:qname/:method', function (req, res) {
}); var classPath = req.params["qname"];
}); var methodName = req.params["method"];
var gname = req.params["gname"];
classPath = gname + "." + classPath;
var params = [];
if (req.loginUser) {
req.query = req.query || {};
req.query.sign_body = req.loginUser.sign_body;
}
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
params.push(res);
var p = null;
var invokeObj = system.getObject("web." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
console.log(req.url, "req.url...................");
console.log(r, "req###############################");
res.end(JSON.stringify(r));
});
});
app.post('/web/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
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;
if (req.loginUser) {
req.body.saas_id = req.loginUser.saas_id;
req.body.sign_body = req.loginUser.sign_body;
}
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
params.push(res);
var p = null;
var invokeObj = system.getObject("web." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
}; };
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