Skip to content

Commit

Permalink
fix: handle refreshing tokens missing expires_at
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Aug 2, 2023
1 parent b829572 commit bcb54ec
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ export const openIDRefreshHandlerFactory: OpenIDRefreshHandlerFactory = (
read,
write
}
) => async function openIDRefreshHandler (request, reply) {
) => async function openIDRefreshHandler(request, reply) {
const oldTokenset = new TokenSet(await read.call(this, request, reply))
if (oldTokenset.expired()) {
request.log.trace(
`OpenID token expired ${oldTokenset.expires_at !== undefined
? new Date(oldTokenset.expires_at * 1000).toUTCString()
: 'recently'
}, refreshing`
if (oldTokenset.expires_at === undefined || oldTokenset.expired()) {
request.log.trace(oldTokenset.expires_at === undefined
? 'OpenID token missing expires_at, refreshing'
: `OpenID token expired ${new Date(oldTokenset.expires_at * 1000).toUTCString()}, refreshing`
)
const newTokenset = await client.refresh(oldTokenset, extras)
const verified = verify !== undefined
Expand Down

0 comments on commit bcb54ec

Please sign in to comment.