Skip to content

Commit

Permalink
fix: remove subpaths from redirect URI and encode it properly (TT-173…
Browse files Browse the repository at this point in the history
…2) (#55)
  • Loading branch information
fredrikmonsen authored Sep 27, 2024
1 parent 3118b6f commit 8184991
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export const AuthProvider = ({children}: { children: React.ReactNode }) => {
if (intervalId) {
clearInterval(intervalId);
}
const currentUrl = window.location.href;
let currentUrl = window.location.href;
// The app dislikes being redirected to a sub-path, redirecting to root to avoid issues
currentUrl = currentUrl.replace(/\/hugin.*/, '/hugin');
currentUrl = encodeURIComponent(currentUrl);

window.location.assign(`${keycloakConfig.url}/realms/${keycloakConfig.realm}/protocol/openid-connect/auth` +
`?client_id=${keycloakConfig.clientId}&redirect_uri=${currentUrl}&response_type=code&scope=openid`);
}, [intervalId]);
Expand All @@ -52,9 +56,6 @@ export const AuthProvider = ({children}: { children: React.ReactNode }) => {
}
} else {
handleNotAuthenticated();
const currentUrl = window.location.href;
window.location.assign(`${keycloakConfig.url}/realms/${keycloakConfig.realm}/protocol/openid-connect/auth` +
`?client_id=${keycloakConfig.clientId}&redirect_uri=${currentUrl}&response_type=code&scope=openid`);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down

0 comments on commit 8184991

Please sign in to comment.