Next.js Server Component role base access with Supabase

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • In this video I am going to show you how to do Role base access with Supabase and Next.js Server Component.
    Code
    github.com/Che...
    Doc and tutorial
    - dev.to/sruhled...
    - • Implement Authorizatio... ‪@Supabase‬
    Support the channel : 🙏🌸
    - donate 🌻: / dailywebcoding
    Follow me: 👇
    - Discord: / discord
    - Github: github.com/Che...

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

  • @DailyWebCoding
    @DailyWebCoding  11 месяцев назад +4

    I think supabase just updated the UI. right now you can do it in the sql editor and create the trigger from there by using this command.
    create trigger after insert on auth.users for each row execute function ();

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

      Apologises for being thick but could you tell me where I need to add this code?
      Thank you again for your help, Mark

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

      @@markbroomfield1818 In supabase dashboard sidebar. You can find SQL Editor. That's where you can run the code above

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

      @@DailyWebCoding Apologies, I understand it needs to be added to the SQL Editor. However, does it need to be attached to anything else or just a seperate code and run? Thanks Mark

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

      @@markbroomfield1818 ruclips.net/video/mcrqn77lUmM/видео.htmlsi=GiVaHvcrioXb9bZY you can check this video. Hope is can help you

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

      @@DailyWebCoding Thank you so much for the quick work around on this.
      Works a treat, great channel and please keep up the amazing work. Thanks Mark

  • @FalconMasters
    @FalconMasters 9 месяцев назад +27

    There is one security problem with that aproach that you all guys have to be aware of.
    If you make a "user" or "profile" table where you store all the user info like, name, avatar, settings, etc and you store the role on that same table you have a security issue there.
    Because you will probably make a Row Level Security where you are going to allow users edit their own row in "user" table, therefore the user will have access to change his own role to "admin".
    To solve this you have to add the "role" column on a different table and that table should have a Row Level Security that only allows to read and not to write/update.

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

      gracias falcon, aprendi mucho de ti en un inicio y vaya sorpresa con el comentario, tienes razon!

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

      @@guillermomarindavila5779 Muchas gracias a ti por ver mis videos, me alegra que te sirvieran!

    • @Sirin-i8j
      @Sirin-i8j Месяц назад +1

      thnx

  • @codewithguillaume
    @codewithguillaume Год назад +11

    Amazing video :) Please continue !

  • @kryptons-galaxy
    @kryptons-galaxy 5 месяцев назад +1

    Perfect tutorial, I was confused with managing the user accesses, this one cleared all the doubts, thanks ❤

  • @superurgmail
    @superurgmail 10 месяцев назад

    Brilliant video - just what I needed. Thanks (and subscribed).

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

    nice video and nice line-height

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

    so clearly. thank you

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

    we want more... ❤ could you do supabase and stripe?

    • @DailyWebCoding
      @DailyWebCoding  Год назад +4

      I will look into that. Thank you for your suggestion.

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

      Yes! stripe-supa -next 13.4-jotai

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

    Great videos, thanks! Could you do one where anyone visiting the site can view the all the posts, but only an admin can update the posts that belong to them?

    • @DailyWebCoding
      @DailyWebCoding  Год назад

      Thank you for your suggestion. I will try to do that.

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

      yes pleaSE ! @@DailyWebCoding

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

    Hello, great tutorial 👍 !
    Everything was going fine until when I needed to select the auth table (timestamp 06:23) 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?
    Can you help. Thanks, Mark

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

      currently facing the same thing right now, did you find the solution?

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

      I think supabase just updated the UI. right now you can do it in the sql editor and create the trigger from there by using this command.
      create trigger after insert on auth.users for each row execute function ();

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

    hi a beginner here, why i cant choose the users from the trigger option right now ?

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

      I think supabase just updated the UI. right now you can do it in the sql editor and create the trigger from there by using this command.
      create trigger after insert on auth.users for each row execute function ();

  • @Michael-Martell
    @Michael-Martell Год назад

    I think a regional manager with several managers with several teams. Managers should only see their teams… etc. I’ve been thinking about how to make this works for several years now as I have learned to code.

  • @user-dm5qi4nb6l
    @user-dm5qi4nb6l 9 месяцев назад +1

    Supabase has a roles column in auth.users I tried to use that but maybe that is not how it is supposed to be used maybe that's only there to be managed for supabase? I created a custom role give it to a user but then when I made the rule it was simply not working, of course I gave the user in auth.users that custom role but then I had to change it back to authenticated then update the rule and it worked normally.

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

      You can check my latest video about role management in supabase Build Role Access Dashboard with Next.js 14,Supabase, Shadcn,Tailwind
      ruclips.net/video/D7BzpvHM6JI/видео.html

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

    nice video, i have a qustion, how can i change the role using params? i need create multiples roles

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

      Currently I am working on a new video about this as well. Stay tuned for that

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

    Are there any security flaws using this method?

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

      Yes, that if you make a row level security that allows the user to update his profile or user info and is on the same table as the rol then he has access to update his role and set it to "admin" giving him self permissions.
      One way to fix this is to have 2 diferent tables for the user, one for his data and other one for his role or permissions.

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

    i am getting this error while sign up AuthApiError: duplicate key value violates unique constraint "user_pkey" as i am created trigger from sql editor

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

    But how to set role while we signup not with supabase?

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

      I need this too 😭 did you ever figure it out?

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

      @@rgorai1029 yeah i make another table that containing userprofile and role and after signup an get token user need to set his role

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

      @@rgorai1029 me too

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

    sir can you create a react version of this please I dont understang nextJS

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

    hey bro can you updated this please I need this and the role please dont just put the role in it manuall make it dynamic, also please take it slow man you kind super fast

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

      Build Role Access Dashboard with Next.js 14,Supabase, Shadcn,Tailwind
      ruclips.net/video/D7BzpvHM6JI/видео.html

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

      You can check this one

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

      @@DailyWebCoding thank you sir, are you able to create a video like this with reactJS alone please

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

    Your head is covering code ... we really didn't need to see your face ... we just needed to see code which we couldn't for your head which makes this video useless ...