-
-
Notifications
You must be signed in to change notification settings - Fork 194
Social Login (OAuth) User Metadata, Invite Shortcomings #670
Description
Bug report
I'm opening this as a bug because I view it as a rather large oversight, rather than a feature request.
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Both the social login system and the invite system seem to have a pretty big hole. The invite system can't use the social login for confirmation, and the social login system doesn't appear to provide any mechanism to provide custom user metadata for insertion into raw_user_meta_data when the auth.user record is created.
The latter need exists because the invites system can't use a social login, so we need some method of conveying metadata - like an invite code we hand roll - into the social login process for new users. We've considered multiple redirect, but that's very sloppy and doesn't play well with webhooks or triggers on auth.users.
The documentation site is just absolutely woeful (https://supabase.com/docs/reference/javascript/auth-signinwithpassword just states the type name with no information about the properties nor link to the type), but the types for the package here outline what's possible and what isn't with regard to user metadata during signup processes.
Nearly all of the signIn/signUp methods include the data option, as can be seen in the types: https://github.com/supabase/gotrue-js/blob/eb96536a441d21fae75d25ab6de346808c6e6044/src/lib/types.ts#L389-L395
Even the Invite and Magic Link methods include the data options: https://github.com/supabase/gotrue-js/blob/eb96536a441d21fae75d25ab6de346808c6e6044/src/lib/types.ts#L539-L544
Except of course, for signInWithOAuth: https://github.com/supabase/gotrue-js/blob/eb96536a441d21fae75d25ab6de346808c6e6044/src/lib/types.ts#L440-L453
Now, granted that allowing the invite system to utilize social/oauth logins would probably be a massive lift, we could in theory get around that by providing metadata to a data option to signInWithOAuth which could contain an invite code with instructions for any webhooks or triggers on the auth.users table.
What about redirectTo then? Well, that's certainly less than optimal. If we were able to use data the workflow would look like this:
- call
signInWithOAuthwithdata: { inviteCode } - social login process completes
auth.usersis updated with new user record- a trigger is executed and
public.profilesis updated nearly instantaneously with data from theinviteCode
Using redirectTo the process takes a completely different shape, without the same speed or fidelity:
- call
signInWithOAuthwithredirectTocontaining a query param with aninviteCode - social login process completes
auth.usersis updated with new user record- client is redirected back to the application to an interstitial page
- interstitial page calls an API to update the use that was created, transmitting the
inviteCodeto updatepublic.profiles - interstitial page waits for a response, and then redirects to the signup-successful page
It's pretty clear that the power and utility of supabase is being neutered by the latter process. Additional redirects aren't a great user experience and are prone to error.
I've been a big proponent of supabase for a few years now publicly and with companies that I've worked for, and this has the potential to convince the leadership for this particular project to look elsewhere for solutions - something I'm pushing back against strongly. That's not intended to be negatively motivating in any way; I simply want to convey the severity of concern around this particular issue. I hope maintainers here will give this earnest consideration.
To Reproduce
n/a
Expected behavior
The data option to exist and be function for SignInWithOAuthCredentials
Screenshots
n/a
System information
- OS: [e.g. macOS, Windows] MacOS Ventura
- Browser (if applies) [e.g. chrome, safari]
- Version of supabase-js: latest
- Version of Node.js: 18.15.0
Additional context
Add any other context about the problem here.