Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-liljeqvist authored Nov 26, 2023
1 parent 99fa351 commit cc1777c
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions demos/supabase-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,41 @@
## 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 "Only authed users can SELECT their row" ON "public"."users"
AS PERMISSIVE FOR SELECT
TO authenticated
USING (true)
```

<img width="2294" alt="Screenshot 2023-11-26 at 12 23 04" src="https://github.com/MoralisWeb3/Moralis-JS-SDK/assets/11097108/994b0697-01cf-4e27-8f56-b9c50ea4b255">

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.

<img width="2276" alt="Screenshot 2023-11-26 at 12 23 48" src="https://github.com/MoralisWeb3/Moralis-JS-SDK/assets/11097108/cee7e888-4901-4ca0-ae61-dfd8418cb7f5">

You should see this if you click on that `1 active RLS policy`. This ensures that only authenticated users can view their data.

<img width="2560" alt="Screenshot 2023-11-26 at 12 24 57" src="https://github.com/MoralisWeb3/Moralis-JS-SDK/assets/11097108/f19956fc-54b0-493b-b7fb-79a0aa3f0b77">



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:

Expand Down

0 comments on commit cc1777c

Please sign in to comment.