Commit 7db020f9 by 王昆

gsb

parent 21aa94be
...@@ -53,15 +53,19 @@ class UserCtl extends CtlBase { ...@@ -53,15 +53,19 @@ class UserCtl extends CtlBase {
} }
var user = await this.service.authByCode(loginrs.data.opencode); var user = await this.service.authByCode(loginrs.data.opencode);
req.session.user = user; req.session.user = user;
return system.getResultSuccess(user);
var xggadminsid = await this.setLogin(user);
return system.getResultSuccess(xggadminsid);
} catch (error) { } catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message); return system.getResultFail(500, "接口异常:" + error.message);
} }
} }
async setLogin(req, res, user) { async setLogin(user) {
var xggadminsid = uuidv4(); var xggadminsid = uuidv4();
await this.redisClient.setWithEx(xggadminsid + "_admin_user", JSON.stringify(user), 60 * 60 * 2); await this.redisClient.setWithEx(xggadminsid, JSON.stringify(user), 60 * 60);
return xggadminsid; return xggadminsid;
} }
......
module.exports = { module.exports = {
// 生产环境
"appid": "728b979f7afd4413ac683344cd4a97fa", "appid": "728b979f7afd4413ac683344cd4a97fa",
// 测试环境
// "appid": "2f41920e82fa46dd98887d81df9457ab",
"label": "研发开放平台", "label": "研发开放平台",
"config": { "config": {
"rstree": { "rstree": {
......
...@@ -7,9 +7,15 @@ const redisClient = system.getObject("util.redisClient"); ...@@ -7,9 +7,15 @@ 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 = req.headers["xggadminsid"] || ""; var xggadminsid;
// var jsonUser = await redisClient.get(xggadminsid);
var jsonUser = req.session.user; var jsonUser = req.session.user;
if(!jsonUser) {
xggadminsid = req.headers["xggadminsid"] || "";
jsonUser = await redisClient.get(xggadminsid);
if(!jsonUser) {
jsonUser = JSON.parse(jsonUser);
}
}
if (req.url.indexOf("auth/userCtl/login") > 0 || if (req.url.indexOf("auth/userCtl/login") > 0 ||
req.url.indexOf("auth/userCtl/smsCode") > 0 || req.url.indexOf("auth/userCtl/smsCode") > 0 ||
...@@ -29,6 +35,10 @@ module.exports = function (app) { ...@@ -29,6 +35,10 @@ module.exports = function (app) {
res.end(JSON.stringify({ status: -99, msg: "no login" })); res.end(JSON.stringify({ status: -99, msg: "no login" }));
return; return;
} }
if(xggadminsid) {
redisClient.setWithEx(xggadminsid, JSON.stringify(jsonUser), 60 * 60);
}
req.loginUser = jsonUser; req.loginUser = jsonUser;
next(); next();
}); });
......
...@@ -19,8 +19,12 @@ var settings = { ...@@ -19,8 +19,12 @@ var settings = {
passroleid: 2, passroleid: 2,
tanentroleid: 1, tanentroleid: 1,
protocalPrefix: "http://", protocalPrefix: "http://",
// 生产环境
appKey: "728b979f7afd4413ac683344cd4a97fa", appKey: "728b979f7afd4413ac683344cd4a97fa",
secret: "f8891fcf37574f5a9f21b3030c302f4a", secret: "f8891fcf37574f5a9f21b3030c302f4a",
// 测试环境
// appKey: "2f41920e82fa46dd98887d81df9457ab",
// secret: "ede9b66ddb964d15b0a543b7ac7bb28f",
salt: "%iatpD1gcxz7iF#B", salt: "%iatpD1gcxz7iF#B",
defaultpwd: "987456", defaultpwd: "987456",
basepath: path.normalize(path.join(__dirname, '../..')), basepath: path.normalize(path.join(__dirname, '../..')),
...@@ -35,7 +39,7 @@ var settings = { ...@@ -35,7 +39,7 @@ var settings = {
}, },
paasUrl: function () { paasUrl: function () {
if (this.env == "dev") { if (this.env == "dev") {
return "http://192.168.18.125:4001/"; return "http://192.168.18.237:4001/";
} else { } else {
return "http://open.gongsibao.com/"; return "http://open.gongsibao.com/";
} }
......
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