#Supabase

Поделиться
HTML-код
  • Опубликовано: 11 июл 2024
  • In this episode I will show you a fantastic technique that will take your application to the next level when new users sign up to your app. With #Supabase, not only can you create an account seamlessly, but it's also the perfect opportunity to set up a detailed profile for each user.
    In this video, we'll demonstrate how to utilise a trigger that constantly monitors the user table, ensuring that as soon as an account is created, a corresponding profile entry is automatically generated. This profile row is uniquely identified by the user's ID, providing a dedicated space to store all the extended profile information within our application.
    To ensure good security, we'll implement a set of policies that lock down our profile table. This guarantees that only authenticated users have read and update access to the data, protecting the privacy of our users and their valuable information.
    As an added bonus, we'll also demonstrate how to include a social media username as the display name in the profile table. This feature adds a personal touch to each user's profile and enhances the overall user experience.
    In this video, we'll be using a #nocode #FlutterFlow project as our example. However, rest assured that this powerful technique can be applied to any front-end stack you prefer. So, let's dive in and unlock the full potential of your application together!
    FlutterFlow project for cloning: app.flutterflow.io/project/su...
    00:00 Introduction
    00:49 What problem are we trying to solve!
    01:23 Creating the profile table
    03:36 Order of events
    04:27 Creating the Supabase function
    07:07 Creating the Supabase trigger
    08:35 Creating a user to test our profile entry
    09:41 Implementing RLS on the profile table
    14:25 FlutterFlow Quick Test
    15:25 BONUS: Social display name entry
    17:25 Outro
    _____
    🚀 The Digital Pro's NoCode Academy on Patreon: www.thedigitalpro.co.uk/patreon
    (official launch in September, but welcome to join today 😉)
    🔥 If you love my content why not consider buying me a coffee, it's really appreciated: www.thedigitalpro.co.uk/coffee
    👍 Support the channel and grab yourself a free FlutterFlow account by clicking here: www.thedigitalpro.co.uk/flutt...
    🎉 Your love is much appreciated ... A like to this video is like a High Five!!! Thank you all.

Комментарии • 79

  • @lucashyde1164
    @lucashyde1164 8 месяцев назад +51

    Here's step-by-step to fix the Auth.Users table not showing when you select trigger.
    TLDR: Supabase thought the users table was too important to let you edit it through their UI so they changed it. You can only access it through code. But don't be afraid!
    1. On the left side bar, click SQL Editor (third icon from the top)
    2. Copy and paste this into your editor :
    create trigger new_user_trigger
    after insert on auth.users for each row
    execute function create_profile_for_new_users ();
    Note : your function have to be called create_profile_for_new_users like it stated in the video.
    I used Supabase AI to on the SQL Editor (The green bar) to generate the code. Here was my prompt "create a trigger in Supabase that reacts to new user sign-ups by inserting a row into another table called Profile".
    Hope this helps!

    • @the_digitalpro
      @the_digitalpro  8 месяцев назад +7

      Awesome thank you Lucas. I really need to do a follow video on this but appreciate you pointing this out. Its very community spirit of you to provide this solution. Such a shame RUclips does not allow video updates.

    • @mrgolddd
      @mrgolddd 8 месяцев назад

      Thank you, I keep getting:
      "Failed to create user: duplicate key value violates unique constraint "profile_email_key" any idea how I fix that?
      after using the steps you described here. before I get a okay but no row is generated in profile

    • @lucashyde1164
      @lucashyde1164 8 месяцев назад +1

      @mrgolddd that's strange but usually when there's an error like that it meant the table isn't set up right. I usually plug such error in chatgpt with context its from supabase and ask it to explain to me how to solve it. Sorry wasn't very helpful but hope that works

    • @hamidrezasalahi6444
      @hamidrezasalahi6444 8 месяцев назад +1

      You are a life saver

    • @Kevin_Knights
      @Kevin_Knights 8 месяцев назад

      Thank you so much @lucashyde1164. I got it working :)

  • @themafisk
    @themafisk 8 месяцев назад +1

    Thank you very much Steve for this tutorial, it was exactly what I was looking for! Straight to the point!

  • @craigschrickker2312
    @craigschrickker2312 7 месяцев назад

    Thank you for the effort and clarity in these videos! Super helpful.

  • @kylekhanh7362
    @kylekhanh7362 5 месяцев назад

    very amazing ! Very clear and full of useful knowledge , thanks

  • @swh9556
    @swh9556 Год назад +1

    Best tutorial!!👍👍👍thanx for the great video

  • @chitzvalerio6396
    @chitzvalerio6396 7 месяцев назад +1

    Very help! Thank u!

  • @delwarhussain8667
    @delwarhussain8667 Год назад +3

    Wow!! Excellent tutorial on Supabase. I have couple of questions. I watched your other series on “Goals tracking” app where you went over creating tables on Supabase at the beginning for creating accounts. Only this time, the difference is you created a “Function” and “Trigger” on Supabase. Do I need to create this “Function” and “Trigger”? Wouldn’t FF populate this automatically when you create an action to insert user details in table fields when user signup?

  • @AdeleCharlesMisstengeitGatuje
    @AdeleCharlesMisstengeitGatuje Месяц назад

    Thank you so much: How can I create an email confirmation flow with supabase and flutter?

  • @soulslord1733
    @soulslord1733 9 месяцев назад

    have you something to delete the user in profile and in auth in the same time?

  • @MAXX_P
    @MAXX_P 8 месяцев назад +1

    Hey there thanks for the amazing video
    I got this error after creating the trigger when I want to add user:
    _Failed to create user: Database error creating new user_
    what should I do?

  • @Tengkuma
    @Tengkuma 5 месяцев назад

    Hi, Can you also explain how to add the user in the storage bucket and delete the folder when the user is deleted

  • @xzatech
    @xzatech 9 месяцев назад

    Now I wonder How can I get the First and Last names from the TextFields on my SignUp Page from FF into the profile table Supabase.

  • @benmajkut618
    @benmajkut618 9 месяцев назад +6

    Hello ​@the_digitalpro ! Everything was going swimingly until when I needed to select the auth table in the trigger ui. Only my public tables were available and not anything else! Is there a reason why I can't make triggers from any of the locked shemas?

    • @the_digitalpro
      @the_digitalpro  9 месяцев назад +2

      Hello. Can you confirm in the video which point you experienced this issue? Just the timestamp will do.

    • @benmajkut618
      @benmajkut618 9 месяцев назад +2

      7:37

    • @HULEG
      @HULEG 9 месяцев назад +2

      Same here :(

    • @pac2001man
      @pac2001man 9 месяцев назад +4

      Same here...function is fine, but trigger creation is only available on public schema tables. This has recently been reported elsewhere too. The only thing I can think of is that Supabase have perhaps changed the way create trigger roles/permissions work?

    • @markbroomfield1818
      @markbroomfield1818 9 месяцев назад +2

      Hi there,
      Great tutorial 👍. I have the same issue.
      Has this been resolved?
      Thanks, Mark

  • @dsl_art_studio
    @dsl_art_studio 11 месяцев назад +1

    I love your tutorials! I've just begun watching this, but I don't see any reference to deleting users. This is something that is not discussed in any videos that I've watched so far :)
    I have lots of test users with no clue as to how to delete them.

    • @the_digitalpro
      @the_digitalpro  11 месяцев назад

      Thank you this is a great point. Have you look at using the Supabase API's?

  • @xzatech
    @xzatech 9 месяцев назад +4

    Is there any Update on this? I needed to select the auth table in the trigger UI. Only my public tables were available and not anything else! Is there a reason I can't make triggers from any of the locked schemas?

    • @xzatech
      @xzatech 9 месяцев назад +2

      This did the trick for me :
      -- inserts a row into public.members
      create function public.handle_new_user()
      returns trigger
      language plpgsql
      security definer set search_path = public
      as $$
      begin
      insert into public.members (id, email)
      values (new.id, new.email);
      return new;
      end;
      $$;
      -- trigger the function every time a user is created
      create trigger on_auth_user_created
      after insert on auth.users
      for each row execute procedure public.handle_new_user();
      Using Supabase
      SQL Editor

    • @the_digitalpro
      @the_digitalpro  9 месяцев назад +1

      Hi. Thank you for your comments on this video. I would like to go back to the video and walkthrough the process again and validate any changes that may have occurred on the Supabase end. This is sometimes the problem with evolving products that certain things change over time which results in having to provide updated videos. Thank you for your info. I'll take a look!

    • @deger.ogretmen
      @deger.ogretmen 7 месяцев назад

      create or replace function insert_user_profile () returns trigger as $$
      BEGIN
      INSERT INTO public.profile (id, email)
      VALUES (NEW.id, NEW.email);
      RETURN NEW;
      END;
      $$ language plpgsql security definer;
      create trigger on_new_user
      after insert on auth.users
      for each row execute procedure

  • @markhorley
    @markhorley 4 месяца назад

    Cannot find how you set up the username input action in this video, please advise. 😊

  • @ezzabbas8561
    @ezzabbas8561 Год назад +1

    Great tutorial, thank you so much for all series you created about flutterflow and supabase. I hope to continue these series. I have a question please, I'm creating an app for school and I need to know how to manage users roles in both flutterflow and supabase. my app has many roles like (App_Admin who manage and create other roles, student, teacher, school_principal, and social_worker), can you please create a tutorial to explain how to do this process? or at least give me an idea about how to create these roles in supabase and how to manage them in flutterflow. Will I create user roles in profile table or there is another way? thank you so much for your support.

    • @the_digitalpro
      @the_digitalpro  Год назад +2

      Hello thank you very much for the kind words and suggestion. There certainly are a number of different ways to implement roles in a FlutterFlow app. I would be happy to do this no problem. Leave it to me. Great suggestion. 👍

    • @DanVanDamme
      @DanVanDamme 9 месяцев назад

      @@the_digitalprowould also like to see this tutorial. I’m trying to build an app that has two types of users, like airbnb, both consumers and hosts and a user can have both roles. Is this best achieved with two user profile tables?

  • @Good-and-Geeky
    @Good-and-Geeky 2 месяца назад +1

    So much has changed on the Supabase end of things I didn't get that to work....

    • @the_digitalpro
      @the_digitalpro  2 месяца назад +1

      You are absolutely right. Products do move on. I would like to produce an update to this video to help people orientate the changes.

  • @jackepner9984
    @jackepner9984 3 месяца назад

    I keep getting errors trying to create the function - undefined variable for public.profile I've checked spelling over and over, no clue what's causing this.

  • @hughgallagher
    @hughgallagher 7 месяцев назад

    There is an alternative way to implement the user profiles. As can be seen in the comments on this video, when you start using database triggers/functions/polices etc you are opening yourself up to a whole WORLD of PAIN. Just create the user profile table as a normal table with user_id text field and when you create an account in FF just add in a Supabase query to update the email and auth id to the email and user_id field in your user profile table. Job done. Also, if you do too much in Supabase then it isn't low/no code... its just db SQL coding which defeats the whole point/ethos of low/no code

    • @the_digitalpro
      @the_digitalpro  7 месяцев назад

      Yes I do agree with your points but you cannot avoid locking down your Supabase database with rules to restrict access. This has to be done with getting your hands dirty. Hopefully the Supabase team will provide helpers. I tried to be careful in any complexity in this video with the hope followers could work out what was going on. Yes nocode it isn't but I could not avoid that at the time. Give it a year we should be good. Hopefully.

    • @isaacdyor4264
      @isaacdyor4264 5 месяцев назад

      Is there a way to do this with signInWithOauth? I don't know how to distinguish between an oauth sign in and oauth signup. I want to use your strategy but I only know how to do it with signup with email.

  • @JonathanCodes-ol1cm
    @JonathanCodes-ol1cm 10 месяцев назад +2

    You should delete to cascade when creating the profile table

    • @the_digitalpro
      @the_digitalpro  10 месяцев назад +1

      You are absolutely correct. In my user delete video I do actually correct this as I forgot to apply this option in this specific video. Thanks for bringing it up here.

  • @KentAJI
    @KentAJI 5 месяцев назад +1

    I cannot see auth -> users table in trigger settings (creation)

    • @the_digitalpro
      @the_digitalpro  5 месяцев назад +1

      Please check the comments on this video because Supabase did an update since the video was recorded. This will resolve your problem.

    • @alixaan__
      @alixaan__ 5 месяцев назад

      ruclips.net/video/mcrqn77lUmM/видео.html

  • @AldrichCarrasco
    @AldrichCarrasco 6 месяцев назад

    7:17 as of today, supabase does not allow to add new trigger in the auth schema, how to solve this ?

    • @SpurgeonB
      @SpurgeonB 5 месяцев назад

      I tried doing it directly at psql console with SQL, but didnt have it working... Any joy at your side?

    • @alixaan__
      @alixaan__ 5 месяцев назад

      @@SpurgeonB ruclips.net/video/mcrqn77lUmM/видео.html

  • @user-zg1xx5hq9o
    @user-zg1xx5hq9o 5 месяцев назад

    Creating triggers for schema auth is disallow.
    Message: Currently viewing triggers from a protected schema
    The auth schema is managed by Supabase and is read-only through the dashboard.
    How to change the settings to allow creating triggers for auth through the dashboard?
    The following schemas are managed by Supabase and are currently protected from write access through the dashboard.
    auth
    cron
    extensions
    information_schema
    net
    pgsodium
    pgsodium_masks
    pgbouncer
    pgtle
    realtime
    storage
    supabase_functions
    supabase_migrations
    vault
    graphql
    graphql_public

  • @hughgallagher
    @hughgallagher 7 месяцев назад

    This just didn't work. I created my function as create_profile_for_new_user , and the used the sql editor to create the trigger which worked but when I test, supabase just throws a generic error error message back it me telling me nothing about what has gone wrong. new user does not work...
    create trigger new_user_trigger
    after insert on auth.users for each row
    execute function create_profile_for_new_user ();

    • @the_digitalpro
      @the_digitalpro  7 месяцев назад

      Hey Hugh. Sorry to hear you are having a few issues. What is odd is that I followed my own tutorial the other day to validate the steps and pretty much it check out okay. I did have to follow the odd steps in the comments but I was up and running. This is the problem with evolving products such as Supabase things do change since the video was recorded. What is your issue you now have?

    • @panzam345
      @panzam345 2 месяца назад

      @@the_digitalpro can you please give as new instructions because as mentioned before we cannot access auth tables to create triggers

  • @reprovedcandy
    @reprovedcandy Месяц назад +1

    Not possible anymore. This guide is dated, please take it down. Triggers works differently now and the schema: auth doesn't allow triggers to be created. Wasted my time.

    • @the_digitalpro
      @the_digitalpro  Месяц назад

      Hello. Yes this version is slightly different. I will have an updated video coming out soon. I do have a written 2024 guide within my NoCode Academy but not a video yet. Watch this space.

    • @the_digitalpro
      @the_digitalpro  Месяц назад

      Just for you checkout my latest video.

  • @jeffchia4
    @jeffchia4 Месяц назад +1

    Wondering if this Auth.jwt() and getting the id from the 'sub', is it going to be the same as just auth.id() = user_id? Do they both provide the same outcome?

  • @josucafd
    @josucafd 11 месяцев назад +5

    Here is showing the following error:
    Failed to create user: Database error creating new user
    BEGIN
    INSERT INTO public.perfilUsuario (id, email)
    VALUES (NEW.id, NEW.email);
    RETURN NEW;
    END;

    • @mayconpelegrini
      @mayconpelegrini 11 месяцев назад +1

      Acho que você é brasileiro, se entendeu isso, pode pular pro texto em português mesmo 🤣🤣
      - english -
      I had the same error, I solved it this way.
      1 - I created the security policies that he creates on 9:40 (I tested it before creating the policies and it wasn't working)
      2 - in the function code check if the name of your profile table is written correctly. In my case the error was occurring because my table was called "profiles" (in the plural) and I had written in the code "public.profile" in the singular, the correct one in my case would be "public.profiles". After fixing those two things, I was able to create the user normally.
      I hope I helped, it took me a while to realize my silly mistake.
      - portuguese -
      Eu estava com o mesmo erro, resolvi da seguinte maneira.
      1 - criei as politicas de segurança que ele cria a partir de 9:40 (testei antes de criar as politicas e não estava funcionando)
      2 - no código da função "function" confira se o nome da sua tabela de perfil esta escrito da maneira correta. No meu caso o erro estava ocorrendo por que minha tabela se chamava "profiles" (no plural) e eu havia escrito no código "public.profile" no singular, o correto no meu caso seria "public.profiles". Depois de corrigir essas duas coisas, eu consegui criar o usuário normalmente.
      Espero ter ajudado, demorei para perceber meu erro bobo.

    • @josucafd
      @josucafd 11 месяцев назад +1

      @@mayconpelegrini kkk
      É nois 👊🏼
      Vlw irmão, vou testar aqui!

    • @mayconpelegrini
      @mayconpelegrini 11 месяцев назад

      @@josucafd 🤜🏼🤛🏼

    • @designerelise
      @designerelise 9 месяцев назад

      Remember the log is your friend - click on the log icon on the left side and you can see the error and what you are doing wrong. Now sometimes it will be really cryptic like in this instance it would say "profile" table does not exist or "profile" relation does not exist - which is a typo in names or forgetting to put public before the table name 😆🤣🤣 its like breadcrumbs to keep you on your toes but once you see enough you get to know what they "could" mean

    • @hughgallagher
      @hughgallagher 7 месяцев назад +1

      @@mayconpelegrini i created the policies as he did and check my function code which is 100% correct... still get the same error.... Failed to create user: Database error creating new user