Skip to content

Commit

Permalink
Add silent renew
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Aug 13, 2024
1 parent 5355867 commit 4973950
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/auth/hooks/useCustomAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export function useCustomAuth(): {
[logout, userAuthorization, auth?.user?.profile?.email]
)

useEffect(
() =>
// the `return` is important - addAccessTokenExpiring() returns a cleanup function
auth?.events?.addAccessTokenExpiring(() => {
auth?.signinSilent()
}),
[auth]
)

useEffect(() => {
if (!auth) {
return
Expand All @@ -61,7 +70,7 @@ export function useCustomAuth(): {
const nextUserAuthorization = await getCurrentUserAuthorization()

setUserAuthorization(nextUserAuthorization)
}, 250)
}, 500)
}
}, [
auth,
Expand Down

0 comments on commit 4973950

Please sign in to comment.