Skip to content

Commit

Permalink
fix(firestore): fix handling update tokens and get auth with firestor…
Browse files Browse the repository at this point in the history
…e/cloud functions (#6)

* fix(update-tokens): fix handleRefreshToken to run after promise

* fix(update-tokens): setTimeout only works out of serveless

* fix(get-auth): fix store_id object source
  • Loading branch information
igorsfreitas authored Feb 14, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 4e09e9c commit e5c6641
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/methods/get-auth.js
Original file line number Diff line number Diff line change
@@ -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())
18 changes: 10 additions & 8 deletions lib/services/update-tokens.js
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit e5c6641

Please sign in to comment.