Commit 4e7e7dbe by 蒋勇

config

parent 49dcfd06
...@@ -145,19 +145,23 @@ class UserService extends ServiceBase { ...@@ -145,19 +145,23 @@ class UserService extends ServiceBase {
var self = this; var self = this;
//先要按照用户名,在统一账户中查找存在性 //先要按照用户名,在统一账户中查找存在性
//如果不存在 //如果不存在
console.log(UserService.consumerUrl(p.userName)) if(settings.env!="dev"){
let consumer = await this.cget(UserService.consumerUrl(p.userName)); console.log(UserService.consumerUrl(p.userName))
if (!consumer.data) { let consumer = await this.cget(UserService.consumerUrl(p.userName));
return null; if (!consumer.data) {
} else {
console.log(JSON.stringify(consumer.data))
let password = consumer.data.tags[1].split("_")[1];
let passwd = system.desEncript(p.password)
let inpassword = this.getEncryptStr(passwd);
if (password != inpassword) {
return null; return null;
} else {
console.log(JSON.stringify(consumer.data))
let password = consumer.data.tags[1].split("_")[1];
let passwd = system.desEncript(p.password)
let inpassword = this.getEncryptStr(passwd);
if (password != inpassword) {
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) {
let token = await self.cmakejwt(userfind.jwtkey, userfind.jwtsecret, null); if(settings.env!="dev"){
rtn.token = token; let token = await self.cmakejwt(userfind.jwtkey, userfind.jwtsecret, null);
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