|
@ -10,9 +10,18 @@ async function login (ctx, next) { |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
|
const params = ctx.request.body; |
|
|
const params = ctx.request.body; |
|
|
|
|
|
|
|
|
const emisLoginRes = await ctx.app.fs.emisRequest.post('login', { |
|
|
let emisLoginRes = null |
|
|
data: params |
|
|
if (params.username && params.password) { |
|
|
}) |
|
|
emisLoginRes = await ctx.app.fs.emisRequest.post('login', { |
|
|
|
|
|
data: { ...params, code: 'POMS' } |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (params.token) { |
|
|
|
|
|
emisLoginRes = await ctx.app.fs.emisRequest.get('user-info', { |
|
|
|
|
|
query: { |
|
|
|
|
|
token: params.token, code: 'POMS' |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (!emisLoginRes) { |
|
|
if (!emisLoginRes) { |
|
|
throw "无此用户,请使用正确的登录信息" |
|
|
throw "无此用户,请使用正确的登录信息" |
|
@ -93,26 +102,6 @@ async function login (ctx, next) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function loginWithToken (ctx) { |
|
|
|
|
|
try { |
|
|
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
|
|
const { token } = ctx.request.body |
|
|
|
|
|
|
|
|
|
|
|
const emisLoginRes = await ctx.app.fs.emisRequest.get('user-info', { |
|
|
|
|
|
query: { token, code: 'POMS' } |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
|
|
|
ctx.body = {} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = { |
|
|
|
|
|
message: typeof error == 'string' ? error : undefined |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function logout (ctx) { |
|
|
async function logout (ctx) { |
|
|
try { |
|
|
try { |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
@ -136,5 +125,4 @@ async function logout (ctx) { |
|
|
module.exports = { |
|
|
module.exports = { |
|
|
login, |
|
|
login, |
|
|
logout, |
|
|
logout, |
|
|
loginWithToken, |
|
|
|
|
|
}; |
|
|
}; |