From 3b3efe5791f4951de0c02adf11c9436a44806dd6 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 23 Aug 2018 20:15:42 +0800 Subject: [PATCH] fix login error --- route/api/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/route/api/index.js b/route/api/index.js index f41bd1b..f21420f 100644 --- a/route/api/index.js +++ b/route/api/index.js @@ -45,7 +45,8 @@ r.post('/login', koaBody(), async (c, n) => { let values = [c.request.body.account] let userAcc = await c.db.query({text, values}) if (userAcc.rowCount === 0) throw genError('NotFound', 'user not found') - if (!comparePassword(c.request.body.password, userAcc.rows[0].password)) throw genError('DataFormat', 'account or password error') + let matchPass = await comparePassword(c.request.body.password, userAcc.rows[0].password) + if (!matchPass) throw genError('DataFormat', 'account or password error') let user = userAcc.rows[0] delete user.password