* feat: redirect to new onboarding flow * Getting started * Brand details * Preview organization brands * Orgs team pages * Invite team steps * Move to global zustand store * Few darkmdoe fixes * Wip onboarding + stripe flow * Default plan state Server Action for gettting slug satus of org * Remove onboardingId * Confirmation prompt * Update old onboarding flow handlers to handle new fields * update onboarding hook * Filter out organization section for none -company emails * Match placeholders to users domain * Drop migration * Wip new onboarding intent * WIP flow for self-hosted. Same service call just split logic * WIP * Add TODO * Use onboarding user type instead of trpc session * WIP * WIP * pass role and team name from onboarding to save in schema * Add test to ensure role + name + team are persisted into onboarding table * migrate roles to enum values * Update ENUM * Fix type error * Redirect if flag is disabled * Revert packages * Revert all packages/* changes to original branch point * Layout fixes + design * Add slugify * Support saving brand,logo and banner * Cleanup * iMobile fixes * More mobile and darkmdoe fixes * Add I18n * Fix lock file * Fix types * Fix types errors * Copy changes
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
export function extractDomainFromEmail(email: string) {
|
|
let out = "";
|
|
try {
|
|
const match = email.match(/^(?:.*?:\/\/)?.*?([\w\-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[\/?#:]|$)/);
|
|
out = (match && match[1]) ?? "";
|
|
} catch (ignore) {}
|
|
return out.split(".")[0];
|
|
}
|
|
|
|
/**
|
|
* Checks if an email is a company email (not a personal email provider)
|
|
*/
|
|
export function isCompanyEmail(email: string): boolean {
|
|
// A list of popular @domains that are personal email providers
|
|
const personalEmailProviders = [
|
|
"gmail.com",
|
|
"yahoo.com",
|
|
"outlook.com",
|
|
"hotmail.com",
|
|
"aol.com",
|
|
"icloud.com",
|
|
"mail.com",
|
|
"protonmail.com",
|
|
"proton.me",
|
|
"zoho.com",
|
|
"yandex.com",
|
|
"gmx.com",
|
|
"fastmail.com",
|
|
"inbox.com",
|
|
"me.com",
|
|
"hushmail.com",
|
|
"live.com",
|
|
"rediffmail.com",
|
|
"tutanota.com",
|
|
"mail.ru",
|
|
"usa.com",
|
|
"qq.com",
|
|
"163.com",
|
|
"web.de",
|
|
"rocketmail.com",
|
|
"excite.com",
|
|
"lycos.com",
|
|
"outlook.co",
|
|
"hotmail.co.uk",
|
|
];
|
|
|
|
const emailParts = email.split("@");
|
|
if (emailParts.length < 2) return false;
|
|
return !personalEmailProviders.includes(emailParts[1].toLowerCase());
|
|
}
|