feat: auto enroll into org as student and oauth improvements

This commit is contained in:
Rotimi Best
2026-05-20 08:32:56 +01:00
parent d21d89f250
commit 71fbb2101c
18 changed files with 482 additions and 21 deletions
@@ -197,6 +197,26 @@ export const getOrganizationBySiteName = async (siteName: string): Promise<TOrga
return organization || null;
};
/**
* Gets an organization by its verified custom domain.
* Only matches rows where isCustomDomainVerified is true so we never auto-enroll
* a signup into an org just because someone pointed DNS at us.
*/
export const getOrganizationByCustomDomain = async (customDomain: string): Promise<TOrganization | null> => {
const [organization] = await db
.select()
.from(schema.organization)
.where(
and(
eq(schema.organization.customDomain, customDomain.toLowerCase()),
eq(schema.organization.isCustomDomainVerified, true)
)
)
.limit(1);
return organization || null;
};
/**
* Gets an organization by ID
* @param id Organization ID