supabase-community / supabase-csharp

A C# Client library for Supabase
https://github.com/supabase-community/supabase-csharp/wiki
MIT License
499 stars 50 forks source link

SignUp sending email template with empty parameters #14

Closed fplaras closed 2 years ago

fplaras commented 2 years ago

I was attempting to signup a user but the email template provided by supabase for confirmation has parameters that are not clear how they can be set or created. For example {{ .FullName }}. Anyone can steer me in the right direction? I have used other methods such as CreateUser as an alternative but it doesn't not trigger an email confirmation to be sent and I could not find a method to trigger an email confirmation request via the client.

acupofjose commented 2 years ago

@fplaras thanks for the question!

Have you followed everything here?

https://supabase.com/docs/reference/javascript/auth-signup (these are the JS docs but they mostly translate).

For the C# Gotrue client, you can add the metadata with the CreateUser method and a service role key. But it looks like I’m missing that user data option on the gotrue SignUp call, so I can add that in!

fplaras commented 2 years ago

I did see that there was an optional object parameter in CreateUser that needed to be eventually a dictionary of <string,object>. I thought it was what I needed to use but I might have had the wrong syntax if it was FullName, full_name or fullName.

The SignUp() method did fire the email confirmation and the configurl parameter is working but I updated the link of that template to redirect to an api controller route but I have to map the query string from the Url to the signature of the controller so that it can be a valid route. The goal I was aiming for was to update some user fields in one of my tables when the email is verified by the user.

acupofjose commented 2 years ago

@fplaras To update some fields, you might be able to make a Postgresql trigger that listens for changes on the Table field: auth.users.confirmed_at. But, you would likely have better luck getting feedback on the discord for something like that!

acupofjose commented 2 years ago

The requested change to SignUp signature is in gotrue-csharp@2.3.0 - I'll include it in the next release for supabase-csharp

fplaras commented 2 years ago

Thank you, this is the snippet of code I have. It is not sending an email confirmation when the user is created and the required email confirmation flag is set on the dashboard. The user does get created. var response= await _client.Auth.CreateUser(configuration["Supabase:SecretKey"],email,password,new { FullName = "Name" });

acupofjose commented 2 years ago

@fplaras I don't believe the CreateUser call actually triggers an email send - the new SignUp function is included in 0.2.10 - please use that! It's being published momentarily.

fplaras commented 2 years ago

@fplaras I don't believe the CreateUser call actually triggers an email send - the new SignUp function is included in 0.2.10 - please use that! It's being published momentarily.

Thank you