1. 15
    Implement Gated Content Using Row Level Security with Supabase
    4m 27s

Implement Gated Content Using Row Level Security with Supabase

InstructorJon Meyers

Share this video with your friends

Send Tweet

We're using Row Level Security (RLS) to enforce authorization rules for each row in the database. This applies to the entire row, not specific columns. Therefore, if we want to create some premium content that is only available to our subscribed users, we need to create another table. Again, we can reference the lesson table's ID, using a foreign key relationship.

We will create a premium_content table that will store the video_url column for each lesson. We will fetch this data on the lesson details page, and write an RLS policy that will only enable read access for subscribed users.

This will ensure that our logged-in user has an active subscription, in order to view the video for our lesson. If the user is not signed in or has not paid for a subscription, they will only see the content from the lesson table.

Lastly, we want to display our video (hosted on YouTube) in an inline video player. For this, we can use the react-player package, and set some simple styling defaults that look great!