Skip to content

Commit

Permalink
change how redirection works after signing in
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDarsa committed Jan 16, 2024
1 parent 8cff175 commit 3c99eb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ app
// organizations end

server.get('*', (req, res) => {
const { query } = req;

const redirect = query.redirect;

if (redirect) {
return res.redirect(301, redirect);
}

return handle(req, res);
});

Expand Down
10 changes: 8 additions & 2 deletions src/lib/withKeycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ export default (App, initialAuth) => {

if (!keycloak.authenticated) {
const urlQuery = queryStringToObject(location.search);
const options = urlQuery.idpHint ? { idpHint: urlQuery.idpHint } : {};

const options = {
redirectUri: `${window.location.origin}?redirect=${location.pathname}`,
};

if (urlQuery.idpHint) {
options['idpHint'] = urlQuery.idpHint;
}

await keycloak.login(options);
}

this.setAuth(keycloak);
}

Expand Down

0 comments on commit 3c99eb4

Please sign in to comment.