Skip to content

Commit

Permalink
Merge pull request #813 from WildMeOrg/10.4_patch_public_url_part_2
Browse files Browse the repository at this point in the history
10.4 patch public url part 2
  • Loading branch information
erinz2020 authored Oct 1, 2024
2 parents 650e8f2 + 1f7acea commit ae08bd3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend/src/models/auth/useLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ export default function useLogin() {
// use .startsWith("/") to prevent open redirects
const successful = get(response, "data.success", false);
const decodedRedirect = decodeURIComponent(new URLSearchParams(location.search).get("redirect"));
const nextLocation = get(response, "data.redirectUrl", null)
|| decodedRedirect.startsWith("/")
? `${new URL(process.env.PUBLIC_URL).pathname}${decodedRedirect}${location.hash}`
: null;

const backendRedirect = get(response, "data.redirectUrl", null);
const reactRedirect = decodedRedirect.startsWith("/")
? `${process.env.PUBLIC_URL}${decodedRedirect}${location.hash}`
: null;

const nextLocation = backendRedirect || reactRedirect;

if (successful) {
let url = nextLocation || `${process.env.PUBLIC_URL}/home`;
Expand Down

0 comments on commit ae08bd3

Please sign in to comment.