Skip to content

Commit bb2c12c

Browse files
committed
[DOP-21436] Handle redirects in KeycloakAuthProvider
1 parent 8ce773d commit bb2c12c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/features/auth/KeycloakLogin/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ export const KeycloakLogin = () => {
1111
const { t } = useTranslation('auth');
1212
const login = useKeycloakLogin();
1313
const [isEnabledRequest, setIsEnabledRequest] = useState(false);
14-
const { isSuccess, isEnabled, isFetching } = useCurrentUserInfo({ enabled: isEnabledRequest, throwOnError: false });
14+
const { isSuccess, isEnabled, isFetching, error } = useCurrentUserInfo({
15+
enabled: isEnabledRequest,
16+
throwOnError: false,
17+
});
1518

1619
useEffect(() => {
17-
if (isSuccess && isEnabled) {
20+
if (!isEnabled) {
21+
return;
22+
}
23+
24+
if (isSuccess) {
1825
login();
26+
} else {
27+
const redirectUrl = (error as any)?.response?.data?.error?.details;
28+
if (redirectUrl) {
29+
window.location.href = redirectUrl;
30+
}
1931
}
2032
}, [login, isSuccess, isEnabled]);
2133

0 commit comments

Comments
 (0)