Supabase.js (Bubble plugin)
  • Setup
    • Basic Setup
      • General notes on Bubble setup
    • Supabase Auth
      • Initializing Auth
      • How to: Login
      • How to: Sign Up
      • How to: MFA
      • Identity linking
    • Supabase Data
      • How to: Fetch Data
      • Data Realtime V2 (beta)
      • Foreign Table
      • How to: Create a Thing
      • How to: Update a thing
      • How to: Delete a thing
      • Data Realtime
      • Optimization Tips
      • Schema Validation
      • Create XML Sitemap
    • Supabase Storage
    • Supabase Realtime
    • Supabase Edge Functions
      • Basic Edge Function
      • Bubble Setup
Powered by GitBook
On this page
  • Retrieve identities linked to a user
  • Link an identity to a user
  • Unlink an identity to a user
  1. Setup
  2. Supabase Auth

Identity linking

PreviousHow to: MFANextSupabase Data

Last updated 1 year ago

This is a similar feature just like how Bubble operates with Oauth providers. If you're logged out, and you've only signed up with email, the next time you're logging in via Google, it will automatically create a new user. However once you Signin via an Oauth provider and you're also logged in, that login will be attached to your User profile.

This is the same in Supabase. Identity Linking allows you to attach any Oauth provider to a User and the next time they login with that, they'll be authenticated as the same user. However we need to link them first.

Retrieve identities linked to a user

This action retrieves all identities linked to a user (which is your Current User). The output will be a Bubble List of Text with the following format as each row:

identity_data.email,identity_data.sub,last_sign_in_at,provider,identity_id As you can see it's a comma separated list, with the relevat info, and each row will contain thes same set of values. What is each value:

  • identity_data.email: the email user for signing in.

  • identity_data.sub: the unique id of the provider itself.

  • last_sign_in: a iso date when the user last signed in using the identity

  • provider: for example: google or email.

  • identity_id: that's the uuid in our table within Supabase.

Within each row, use the :splitby operator and find the relevant item you'd like to reference.

Link an identity to a user

The Enable Manual Linking option must be enabled from your project's authentication settings. Once this action called, the same action will happen as the regular "Sign in through OAuth", you'll also have the same options, the only difference will be the event triggered: "New Identity has been linked to User"

If the user tries to link a Google account which has already been used for authentication for themself or for other users, the linking action will fail.

Unlink an identity to a user

For whatever reason you'd like to do this, you can unlink any identity from a user, just by providing what social login provider was used, and the plugin will unlink it from the user. But it won't log them out.

If your user logged in with Google, and doesn't have any other identity

Let's say your user logged in with Google, and doesn't have any other identity. If you try to unlink Google it will throw an error: User must have at least 1 identity after unlinking