Skip to content

Commit 4973950

Browse files
committed
Add silent renew
1 parent 5355867 commit 4973950

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

frontend/src/auth/hooks/useCustomAuth.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ export function useCustomAuth(): {
3939
[logout, userAuthorization, auth?.user?.profile?.email]
4040
)
4141

42+
useEffect(
43+
() =>
44+
// the `return` is important - addAccessTokenExpiring() returns a cleanup function
45+
auth?.events?.addAccessTokenExpiring(() => {
46+
auth?.signinSilent()
47+
}),
48+
[auth]
49+
)
50+
4251
useEffect(() => {
4352
if (!auth) {
4453
return
@@ -61,7 +70,7 @@ export function useCustomAuth(): {
6170
const nextUserAuthorization = await getCurrentUserAuthorization()
6271

6372
setUserAuthorization(nextUserAuthorization)
64-
}, 250)
73+
}, 500)
6574
}
6675
}, [
6776
auth,

0 commit comments

Comments
 (0)