Skip to content

Commit

Permalink
fix(refresh): reset refresh timer if refreshToken is called manually
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoPedroAS51 committed Mar 1, 2020
1 parent 04a3473 commit c892cc9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/core/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,18 @@ export default class Auth {
return Promise.resolve()
}

return Promise.resolve(this.strategy._refreshToken()).catch(error => {
this.callOnError(error, { method: 'refreshToken' })
return Promise.reject(error)
})
return Promise.resolve(this.strategy._refreshToken())
.then(() => {
// Reset the refresh interval
if (this.strategy._scheduleTokenRefresh) {
clearInterval(this.strategy.refreshInterval)
this.strategy._scheduleTokenRefresh()
}
})
.catch(error => {
this.callOnError(error, { method: 'refreshToken' })
return Promise.reject(error)
})
}

// ---------------------------------------------------------------
Expand Down

0 comments on commit c892cc9

Please sign in to comment.