Commit 4e7e7dbe by 蒋勇

config

parent 49dcfd06
...@@ -145,6 +145,7 @@ class UserService extends ServiceBase { ...@@ -145,6 +145,7 @@ class UserService extends ServiceBase {
var self = this; var self = this;
//先要按照用户名,在统一账户中查找存在性 //先要按照用户名,在统一账户中查找存在性
//如果不存在 //如果不存在
if(settings.env!="dev"){
console.log(UserService.consumerUrl(p.userName)) console.log(UserService.consumerUrl(p.userName))
let consumer = await this.cget(UserService.consumerUrl(p.userName)); let consumer = await this.cget(UserService.consumerUrl(p.userName));
if (!consumer.data) { if (!consumer.data) {
...@@ -158,6 +159,9 @@ class UserService extends ServiceBase { ...@@ -158,6 +159,9 @@ class UserService extends ServiceBase {
return null; return null;
} }
} }
}
var rtn = {} var rtn = {}
return this.db.transaction(async function (t) { return this.db.transaction(async function (t) {
//从缓存中取得 //从缓存中取得
...@@ -168,8 +172,13 @@ class UserService extends ServiceBase { ...@@ -168,8 +172,13 @@ class UserService extends ServiceBase {
// }); // });
let userfind = await self.cacheManager["UserCache"].cache(p.userName) let userfind = await self.cacheManager["UserCache"].cache(p.userName)
if (userfind) { if (userfind) {
if(settings.env!="dev"){
let token = await self.cmakejwt(userfind.jwtkey, userfind.jwtsecret, null); let token = await self.cmakejwt(userfind.jwtkey, userfind.jwtsecret, null);
rtn.token = token; rtn.token = token;
}else{
rtn.token = p.userName;
}
let roleids = userfind.Roles.map(item => { let roleids = userfind.Roles.map(item => {
return item.id return item.id
......
...@@ -19,8 +19,25 @@ module.exports = function (app) { ...@@ -19,8 +19,25 @@ module.exports = function (app) {
app.use(bodyParser.json({ limit: '50mb' })); app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true })); app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
routes(app);//初始化路由 routes(app);//初始化路由
app.use(history()); app.use(history());
app.use(express.static(path.join(settings.basepath, '/app/front/entry/public'))); app.use(express.static(path.join(settings.basepath, '/app/front/entry/public')));
app.all('*',function (req, res, next) {
// res.header('Access-Control-Allow-Origin', '*');
// res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// res.header("P3P","CP=CAO PSA OUR");
// res.header('Access-Control-Allow-Credentials', 'true');
if (req.method == 'OPTIONS') {
res.send(200);
}
else {
next();
}
});
// development only // development only
if ('development' == app.get('env')) { if ('development' == app.get('env')) {
app.use(errorHandler()); app.use(errorHandler());
......
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