Changing email
I am using magic links and google auth for login. I plan on having a settings page where poeple can change their account. I see that once you have an email you can sign in and regardless which method its the same account. Can someone be allowed to change emails though? magic link seems doable but what would happen to the google account attached?
10 Replies
Yes this can be done. The Google account would still be attached to the same user as the identity would be saved to this account already. If this is not the desired outcome you can use the
unlinkIdentity
to remove the Google account from this user. https://supabase.com/docs/reference/javascript/auth-unlinkidentityJavaScript: Unlink an identity from a user | Supabase Docs
Supabase API reference for JavaScript: Unlink an identity from a user
hmmm i have a google provider. if i want to change it i cvant until i have another provider so i can disconnect this one . but i dont see that email is considered a rpovider. so i cant seem to add email
how do i add a email as a provider manually? i tried updating user with email i tried link identitiy but email is not a valid provider :/
What do you mean by provider?
Once you sign in with Google, you just updateUser and pass the new email. That’s all it is.
i currenlty have google provider. now i wanrt to add my email as one of the providers. it will be klisted in the column providers.
const { error } = await supabase.auth.updateUser({
email: newEmail,
});
this doesnt work
This works. It's what I'm doing in my code that I tested. If you have email confirmation on, you will get an email sent to the new email address and the existing one from the Google provider. Once you confirm those emails via a link sent to you, it will update to the new email in the database.
it seems to be working now. for a little while it was sending a email with numbers for confirming. but i use magic links and dont require a number o anything like that
i see. i think i figured out the issue. if im already signed up with that email via google provider, i can no longer add the same email as a magic link?
I don’t think you would need to add it as a provider as you should still be able to sign in with magic link of the email is the same.
well i switched on mnamually link identities so poeple could technically change their google identity and or email
I don't understand what you mean by this? an email isn't linked, it is updated using the
updateUser
method. Only OAuth providers uses the linkIdentity
method.i gave users the option to use google or magic link. if they decide they want to change their email i didnt want the magic link and the google auth to be connected. maybe they want to sign in via google on one email address or maybe they have a magic link with a different address
so i set the manual identities