diff --git a/lib/methods/get-auth.js b/lib/methods/get-auth.js index 88e1e9a..84fad7d 100644 --- a/lib/methods/get-auth.js +++ b/lib/methods/get-auth.js @@ -51,7 +51,7 @@ const getAuth = ({ dbFilename, db, table }) => { } query.get() .then(row => { - if (row.empty || (row.store_id !== storeId)) { + if (row.empty || (row.docs[0].data().store_id !== storeId)) { handleRejectPromise(reject) } else { handleResolvePromise(resolve, row.docs[0].data()) diff --git a/lib/services/update-tokens.js b/lib/services/update-tokens.js index b037fd7..542c2a0 100644 --- a/lib/services/update-tokens.js +++ b/lib/services/update-tokens.js @@ -43,18 +43,20 @@ const updateTokens = (client) => { values.map(item => { rows = rows.concat(item.docs) }) + if (rows && rows.length > 0) { + rows.map(row => { + handleRefreshToken(row.data()) + }) + } }) - if (rows && rows.length > 0) { - rows.map(row => { - handleRefreshToken(row.data()) - }) - } } } - // run task with 1 hour interval - const hour = 60 * 60 * 1000 - setInterval(task, hour) + // if database engine is sqlite, run task with 1 hour interval + if (dbFilename) { + const hour = 60 * 60 * 1000 + setInterval(task, hour) + } task() }