Skip to content

Commit

Permalink
feat: allow multiple audiences
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveOrDead committed Jan 17, 2024
1 parent 0158bd6 commit f7b48a6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/createKindeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ const createKindeClient = async (
searchParams.start_page = start_page;
}

if (audience) {
searchParams.audience = audience;
}

if (org_code) {
searchParams.org_code = org_code;
}
Expand All @@ -308,9 +304,21 @@ const createKindeClient = async (
searchParams.org_name = org_name;
}

url.search = String(
new URLSearchParams(Object.assign(authUrlParams, searchParams))
const urlSearchParams = new URLSearchParams(
Object.assign(authUrlParams, searchParams)
);

if (audience) {
/* if multiple audiences requested it should appear multiple times in the query string */
audience
.trim()
.split(/\s+/)
.forEach((aud) => {
urlSearchParams.append('audience', aud);
});
}
url.search = String(urlSearchParams);

window.location.href = url.toString();
};

Expand Down

0 comments on commit f7b48a6

Please sign in to comment.