Skip to content

Commit

Permalink
fix: no longer errors on pw reset
Browse files Browse the repository at this point in the history
  • Loading branch information
YazeedLoonat committed Dec 14, 2023
1 parent 7c0ca1c commit ddb3f60
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions shared-helpers/src/AuthContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ const scheduleTokenRefresh = (accessToken: string, onRefresh: (accessToken: stri
return null
} else {
// Queue up a refresh for ~1 minute before the token expires
return (setTimeout(() => {
return setTimeout(() => {
const run = async () => {
const reposne = await new AuthService().token()
if (reposne) {
onRefresh(reposne.accessToken)
}
}
void run()
}, Math.max(ttl - 60000, 0)) as unknown) as number
}, Math.max(ttl - 60000, 0)) as unknown as number
}
}
const reducer = createReducer(
Expand Down Expand Up @@ -316,7 +316,10 @@ export const AuthProvider: FunctionComponent<React.PropsWithChildren> = ({ child
},
})
if (response) {
dispatch(saveToken({ accessToken: response.accessToken, apiUrl, dispatch }))
await new Promise((resolve) => {
dispatch(saveToken({ accessToken: response.accessToken, apiUrl, dispatch }))
resolve(true)
})
const profile = await userService?.userControllerProfile()
if (profile) {
dispatch(saveProfile(profile))
Expand Down

0 comments on commit ddb3f60

Please sign in to comment.