supabase-community / auth-ui

Pre-built Auth UI for React
https://supabase.com/docs/guides/auth/auth-helpers/auth-ui
MIT License
488 stars 121 forks source link

Add the ability to enable the shouldCreateUser on passwordless login #262

Open albertocubeddu opened 4 months ago

albertocubeddu commented 4 months ago

What kind of change does this PR introduce?

What is the current behavior?

You're not able to provide any additional data, therefore you can't decide if you want to create users when a customer uses OTP.

What is the new behavior?

Passing the proper option, you'll be able to decide if you want to have shouldCreateUser

 <Auth
    supabaseClient={supabase}
    additionalData={{ shouldCreateUser: false }}
    view={view.id}

Furthermore, we're using the SignInWithPasswordlessCredentials and we are adding the ability to pass data too

const signInOptions: SignInWithPasswordlessCredentials = {
      email,
      options: {
        emailRedirectTo: redirectTo,
        data: restData,
        ...(shouldCreateUser !== undefined && { shouldCreateUser }),

Additional context

I've decided to re-use the additionalData, as it's used on another component, and it seems to continue with the logic of the original author.