improve signup container
This commit is contained in:
@@ -5,6 +5,7 @@ type SupabaseExternalProvider = Provider | 'email';
|
||||
interface SupabaseAuthSettings {
|
||||
external: Record<SupabaseExternalProvider, boolean>;
|
||||
disable_signup: boolean;
|
||||
mailer_autoconfirm: boolean;
|
||||
}
|
||||
|
||||
export class AuthProvidersService {
|
||||
@@ -61,6 +62,10 @@ export class AuthProvidersService {
|
||||
return process.env.NEXT_PUBLIC_AUTH_PASSWORD === 'true';
|
||||
}
|
||||
|
||||
isMailerAutoconfirmEnabled({ settings }: { settings: SupabaseAuthSettings | null }): boolean {
|
||||
return settings?.mailer_autoconfirm === true;
|
||||
}
|
||||
|
||||
isMagicLinkEnabled(): boolean {
|
||||
return process.env.NEXT_PUBLIC_AUTH_MAGIC_LINK === 'true';
|
||||
}
|
||||
@@ -105,10 +110,11 @@ export class AuthProvidersService {
|
||||
|
||||
async getAuthConfig() {
|
||||
const settings = await this.fetchAuthSettings();
|
||||
const [passwordEnabled, magicLinkEnabled, oAuthProviders] = await Promise.all([
|
||||
const [passwordEnabled, magicLinkEnabled, oAuthProviders, isMailerAutoconfirmEnabled] = await Promise.all([
|
||||
this.isPasswordEnabled({ settings }),
|
||||
this.isMagicLinkEnabled(),
|
||||
this.getEnabledOAuthProviders({ settings }),
|
||||
this.isMailerAutoconfirmEnabled({ settings }),
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -118,6 +124,7 @@ export class AuthProvidersService {
|
||||
oAuth: oAuthProviders,
|
||||
},
|
||||
displayTermsCheckbox: authConfig.displayTermsCheckbox,
|
||||
isMailerAutoconfirmEnabled,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,19 @@ const DynamicAuthConfigSchema = z.object({
|
||||
oAuth: providers.array(),
|
||||
}),
|
||||
displayTermsCheckbox: z.boolean().describe('Whether to display the terms checkbox during sign-up.'),
|
||||
isMailerAutoconfirmEnabled: z.boolean().describe('Whether Supabase sends confirmation email automatically.'),
|
||||
});
|
||||
|
||||
export type DynamicAuthConfig = {
|
||||
providers: {
|
||||
password: boolean;
|
||||
magicLink: boolean;
|
||||
oAuth: Provider[];
|
||||
};
|
||||
displayTermsCheckbox: boolean | undefined;
|
||||
isMailerAutoconfirmEnabled: boolean;
|
||||
}
|
||||
|
||||
export async function getDynamicAuthConfig() {
|
||||
const authService = createAuthProvidersService();
|
||||
const dynamicProviders = await authService.getAuthConfig();
|
||||
@@ -20,6 +31,7 @@ export async function getDynamicAuthConfig() {
|
||||
const config = {
|
||||
providers: dynamicProviders.providers,
|
||||
displayTermsCheckbox: dynamicProviders.displayTermsCheckbox,
|
||||
isMailerAutoconfirmEnabled: dynamicProviders.isMailerAutoconfirmEnabled,
|
||||
};
|
||||
|
||||
return DynamicAuthConfigSchema.parse(config);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
createPath,
|
||||
getTeamAccountSidebarConfig,
|
||||
} from './team-account-navigation.config';
|
||||
import { getCachedAuthConfig, getServerAuthConfig } from './dynamic-auth.config';
|
||||
import { DynamicAuthConfig, getCachedAuthConfig, getServerAuthConfig } from './dynamic-auth.config';
|
||||
|
||||
export {
|
||||
appConfig,
|
||||
@@ -21,4 +21,5 @@ export {
|
||||
personalAccountNavigationConfig,
|
||||
getCachedAuthConfig,
|
||||
getServerAuthConfig,
|
||||
type DynamicAuthConfig,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user