From 4025f367fe29ff4052a943498d80aa44acb024a8 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 1 Dec 2022 10:43:52 +0800 Subject: [PATCH] =?UTF-8?q?login=20=E5=85=BC=E5=AE=B9=20token=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/auth/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index cfcc1f1..76d2d73 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -9,9 +9,18 @@ async function login (ctx, next) { try { const params = ctx.request.body; - const emisLoginRes = await ctx.app.fs.emisRequest.post('login', { - data: params - }) + let emisLoginRes = null + if (params.username && params.password) { + emisLoginRes = await ctx.app.fs.emisRequest.post('login', { + data: { ...params, } + }) + } else if (params.token) { + emisLoginRes = await ctx.app.fs.emisRequest.get('user-info', { + query: { + token: params.token, + } + }) + } if (!emisLoginRes) { throw "无此用户,请使用正确的登录信息"