Skip to content

Commit

Permalink
[Fix #570] Fix kc login when in dev mode in IDE
Browse files Browse the repository at this point in the history
- make sure UserManager.signinRedirectCallback is called only once using
  • Loading branch information
kostobog committed Aug 23, 2024
1 parent 79cb609 commit 6fc6b1d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/misc/oidc/OidcSignInCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ import { getUserManager } from "@utils/OidcUtils";

const OidcSignInCallback = () => {
useEffect(() => {
const key = "cb-in-progress";
if (sessionStorage.getItem(key)) return;
sessionStorage.setItem(key, "in progress");
getUserManager()
.signinRedirectCallback()
.then(() => {
sessionStorage.removeItem(key);
const searchParams = new URLSearchParams(location.search);
if (!searchParams.has("forward_uri")) {
throw Error("Missing parameter forward_uri");
}
const forwardUri = window.atob(searchParams.get("forward_uri"));
window.location.replace(forwardUri);
})
.catch(() => {
sessionStorage.removeItem(key);
});
}, []);

Expand Down

0 comments on commit 6fc6b1d

Please sign in to comment.