Skip to content

Commit

Permalink
fix: refresh not work
Browse files Browse the repository at this point in the history
  • Loading branch information
ronger-x committed Apr 28, 2024
1 parent 7ea5dfc commit cec79ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/runtime/composables/refresh/use-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ const getSession: ReturnType<typeof useLocalAuth>['getSession'] = async (
let authToken = token.value

if (!authToken && !getSessionOptions.force) {
if (refreshToken.value) {
return
}
if (authToken && refreshToken.value && lastRefreshedAt && lastRefreshedAt.value) {
const isTokenExpired =
new Date().getTime() - lastRefreshedAt.value.getTime() > config.token.maxAgeInSeconds * 1000
if (isTokenExpired) {
await refresh({ refreshToken: refreshToken.value })
authToken = useAuthState().token.value
} else {
return
}
}

Expand Down

0 comments on commit cec79ba

Please sign in to comment.