Skip to content

Node.js based forum software built for the modern web

fix: token verify

Barış Soner Uşaklı04dab1d550cd
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) {