diff --git a/demos/supabase-auth/README.md b/demos/supabase-auth/README.md index 9bfb5cac69..1da193c84a 100644 --- a/demos/supabase-auth/README.md +++ b/demos/supabase-auth/README.md @@ -3,9 +3,40 @@ ## Run locally 1. Create a supabase account here https://app.supabase.com/ -2. Copy `.env.example` to `.env` and fill in the values from your supabase dashboard and add the moralis api key -3. Open `public/script.js`, and fill in the values (located at the top of the file) from your supabase dashboard -4. Run `yarn dev` to run the server locally +2. You need to setup your Supabase Database so it can store your users. Go to `SQL Editor` in your Supabase account and run the following SQL query: + +``` +create table + public.users ( + id bigint generated by default as identity, + created_at timestamp with time zone not null default now(), + moralis_provider_id character varying null, + metadata json null, + constraint users_pkey primary key (id) + ) tablespace pg_default; + +alter table "public"."users" enable row level security; + +create policy "Individuals can view their own user records." +on users for select +using ( (auth.jwt() ->> 'id')::bigint = id); +``` + +Screenshot 2023-11-26 at 12 23 04 + +If you view your database, you can double-check that the query was executed correctly. You should see a table called `users` with the following columns and `1 active RLS policy` at the top. + +Screenshot 2023-11-26 at 12 23 48 + +You should see this if you click on that `1 active RLS policy`. This ensures that only authenticated users can view their data. + +Screenshot 2023-11-26 at 12 24 57 + + + +4. Copy `.env.example` to `.env` and fill in the values from your supabase dashboard and add the moralis api key +5. Open `public/script.js`, and fill in the values (located at the top of the file) from your supabase dashboard +6. Run `yarn dev` to run the server locally Now your server is running locally with the following endpoints: diff --git a/demos/supabase-auth/src/config.ts b/demos/supabase-auth/src/config.ts index 1cd03d9514..4fa368ae07 100644 --- a/demos/supabase-auth/src/config.ts +++ b/demos/supabase-auth/src/config.ts @@ -18,5 +18,5 @@ export default cleanEnv(process.env, { SUPABASE_SERVICE_KEY: str(), - CLIENT_URL: str() + CLIENT_URL: str(), });