diff --git a/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx b/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx index 549814e435db..2a58540d1385 100644 --- a/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx +++ b/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx @@ -62,7 +62,7 @@ interface AuthContextApi { loggedOut: boolean; providers: string[] | null; hasPasswordLogin: () => boolean; - hasCorporateEmail: () => boolean; + hasCorporateEmail: (email?: string) => boolean; login: AuthLogin; loginWithOAuth: (provider: OAuthProviders) => Observable; signUpWithEmailLink: (form: { name: string; email: string; password: string; news: boolean }) => Promise; @@ -116,6 +116,7 @@ export const AuthenticationProvider: React.FC> user_id: firebaseUser.uid, name: user.name, email: user.email, + isCorporate: ctx.hasCorporateEmail(user.email), // Which login provider was used, e.g. "password", "google.com", "github.com" provider: firebaseUser.providerData[0]?.providerId, ...getUtmFromStorage(), @@ -187,8 +188,8 @@ export const AuthenticationProvider: React.FC> hasPasswordLogin(): boolean { return !!state.providers?.includes("password"); }, - hasCorporateEmail(): boolean { - return !FREE_EMAIL_SERVICE_PROVIDERS.some((provider) => state.currentUser?.email.endsWith(`@${provider}`)); + hasCorporateEmail(email: string | undefined = state.currentUser?.email): boolean { + return !FREE_EMAIL_SERVICE_PROVIDERS.some((provider) => email?.endsWith(`@${provider}`)); }, async login(values: { email: string; password: string }): Promise { await authService.login(values.email, values.password);