Supabase set password after email invite

Viewed 1553

In a Supabase app, I want to invite users (instead of them signing themselves up). I can invite a user with their email, but they get sent a link which directly authenticates them (like a magic link).

I rather have the user set their password the first time they get into the app. This way, the user would be able to log out and log back in again.

So what I'm looking for is more like a regular signup with email verification, only the order switched around: First you get an email, then you set your password.

Is that even possible with Supabase? If so, how? Or is this just old-fashioned thinking of me and should I go for the way the email invite is set up by Supabase?

1 Answers

I just found an answer on github discussions, where the same question was discussed at the same time.

Since the user is already authed, you can get update the user with their new password:

const { data, error } = await supabase.auth.update({ password: "password" });

Leaving it here for future reference / others who may have the same question. More details on the github thread below:

https://github.com/supabase/supabase/discussions/3208

Related