Skip to content

Commit

Permalink
Merge pull request #58 from kinde-oss/feat/multiple-audiences
Browse files Browse the repository at this point in the history
feat: allow multiple audiences
  • Loading branch information
peterphanouvong authored Jan 18, 2024
2 parents 0158bd6 + f7b48a6 commit 7cd2e30
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 7cd2e30

Please sign in to comment.