Commit 7b70c9cd by 王昆

gsb

parent 1efbfed3
......@@ -5,37 +5,37 @@ var userCtl = system.getObject("web.auth.userCtl");
const redisClient = system.getObject("util.redisClient");
module.exports = function (app) {
// app.all("/web/*", async function (req, res, next) {
// let bpostatsid = req.headers["bpostatsid"] || "";
// jsonUser = await redisClient.get(bpostatsid);
// if (jsonUser) {
// jsonUser = JSON.parse(jsonUser);
// }
//
// if (req.url.indexOf("auth/userCtl/login") > 0 ||
// req.url.indexOf("auth/userCtl/register") > 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 (bpostatsid) {
// redisClient.setWithEx(bpostatsid, JSON.stringify(jsonUser), 60 * 60 * 60);
// }
//
// req.loginUser = jsonUser;
// next();
// });
app.all("/web/*", async function (req, res, next) {
let bpostatsid = req.headers["bpostatsid"] || "";
jsonUser = await redisClient.get(bpostatsid);
if (jsonUser) {
jsonUser = JSON.parse(jsonUser);
}
if (req.url.indexOf("auth/userCtl/login") > 0 ||
req.url.indexOf("auth/userCtl/register") > 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 (bpostatsid) {
redisClient.setWithEx(bpostatsid, JSON.stringify(jsonUser), 60 * 60 * 60);
}
req.loginUser = jsonUser;
next();
});
app.get("/", async function (req, res) {
res.render("index", {appinfo: null, app: null});
......
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