Skip to content

Commit 92c7f72

Browse files
authored
[JN-499] prevent multiple hub oauth redirects (#510)
1 parent 218ee9c commit 92c7f72

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ui-participant/src/login/RedirectFromOAuth.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ export const RedirectFromOAuth = () => {
5050
// * handle possible study enrollment
5151
// * navigate to the hub
5252
// TODO: remember where the user was trying to go and navigate there instead of hard-coding /hub
53+
5354
const email = auth.user.profile.email as string
5455
const accessToken = auth.user.access_token
5556

5657
// Register or login
5758
const loginResult = auth.user.profile.newUser
5859
? await Api.register({ preRegResponseId, email, accessToken })
5960
: await Api.tokenLogin(accessToken)
61+
6062
loginUser(loginResult, accessToken)
6163

6264
// Decide if there's a study that has either been explicitly selected or is implicit because it's the only one
@@ -94,7 +96,12 @@ export const RedirectFromOAuth = () => {
9496
}
9597

9698
handleRedirectFromOauth()
97-
})
99+
/**
100+
* only process redirect logic if the auth token has changed. Previously, we were redirecting
101+
* on all rerenders, which was leading to multiple redirects if, for example, the useUser() was
102+
* updated in response to the loginUser() call
103+
*/
104+
}, [auth.user?.access_token])
98105

99106
return <PageLoadingIndicator />
100107
}

0 commit comments

Comments
 (0)