org discovery on register

This commit is contained in:
peintnermax
2024-08-26 09:50:19 +02:00
parent 2f843621bf
commit 50c360c0cf
2 changed files with 11 additions and 1 deletions

View File

@@ -117,6 +117,7 @@ export async function POST(request: NextRequest) {
const matched = ORG_SUFFIX_REGEX.exec(loginName);
const suffix = matched?.[1] ?? "";
// this just returns orgs where the suffix is set as primary domain
const orgs = await getOrgsByDomainSuffix(suffix);
orgToRegisterOn =
orgs.result && orgs.result.length === 1

View File

@@ -295,7 +295,16 @@ export async function listUsers({
export async function getOrgsByDomainSuffix(domain: string) {
return orgService.listOrganizations(
{ queries: [{ query: { case: "domainQuery", value: { domain } } }] },
{
queries: [
{
query: {
case: "domainQuery",
value: { domain, method: TextQueryMethod.EQUALS },
},
},
],
},
{},
);
}