From 04dab1d550cdebf4c1567bca9a51f8b9ca48a500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 25 Oct 2021 13:23:54 -0400 Subject: [PATCH] fix: token verify --- src/routes/authentication.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index d6b98aa057..6d7a36e037 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -44,13 +44,9 @@ Auth.getLoginStrategies = function () { }; Auth.verifyToken = async function (token, done) { - let { tokens = [] } = await meta.settings.get('core.api'); - tokens = tokens.reduce((memo, cur) => { - memo[cur.token] = cur.uid; - return memo; - }, {}); - - const uid = tokens[token]; + const { tokens = [] } = await meta.settings.get('core.api'); + const tokenObj = tokens.find(t => t.token === token); + const uid = tokenObj ? tokenObj.uid : undefined; if (uid !== undefined) { if (parseInt(uid, 10) > 0) {