Account-System-Demo/README.md
2024-07-17 21:05:04 -04:00

83 lines
No EOL
2.7 KiB
Markdown

## Todo List
- [x] Add loading feedback with ViewTransition API
- [x] Revamp Design and Layout
- [x] Anomymous Account Creation
- [x] Email Confirmation Code
- [x] Ability to:
- [x] Update Data
- [x] Avatar
- [x] Username
- [x] Email
- [x] Pasword
- [x] Delete Account
- [x] Banners (Success and Error Messages)
- [ ] ~~Password Recovery~~ (Failed)
- [ ] ~~Custom Error Pages from Supabase Reponse (400)~~ (FAILED)
- [ ] ~~Passwordless Login (OTP Email)~~ (FAILED)
## Setting Up Supabase
### Selfhosting
This section is optional on wheather or not you want to either use Supabase Cloud or selfhost.
Run:
```bash
# Get the code using git sparse checkout
git clone --filter=blob:none --no-checkout https://github.com/supabase/supabase
cd supabase
git sparse-checkout set --cone docker && git checkout master
# Go to the docker folder
cd docker
# Copy the fake env vars
cp .env.example .env
# Pull the latest images
docker compose pull
# Start the services (in detached mode)
docker compose up -d
```
> Source: https://supabase.com/docs/guides/self-hosting/docker
In the `.env` file that've you copied from `.env.example, you'll need to change some things to adapt it to this project.
- Change `SITE_URL` to `http://localhost:4321`
- Setup SMTP (Project was tested with [Resend](https://resend.com))
For production use, make sure to follow all instructions needed from https://supabase.com/docs/guides/self-hosting/docker.
> SMTP is required for email verification, as a code is required. The end-user is not allowed to login yet until their email is verified.
### Allowing Account Deletion
When an end-user wants to delete their account, they'll be directed to `/api/account/delete`. This API requires that a function already exist in your Supabase project called `delete_user()`.
In the SQL Editor, enter the following and click Run:
```sql
CREATE or replace function delete_user()
returns void
LANGUAGE SQL SECURITY DEFINER
AS $$
delete from auth.users where id = auth.uid();
$$;
```
> Source: https://github.com/orgs/supabase/discussions/250#discussioncomment-5361165
### Table Creation
For this project, two tables need to exist and that is both `channels` and `subs`.
For the `channels` portion, you can import the premade CSV file made for this project.
For the `subs` portion, enter the following in the SQL Editor and click Run:
```sql
create table
public.subs (
"Id" text not null,
"UserSubscribed" text not null,
"Platform" text null,
constraint subs_pkey primary key ("Id", "UserSubscribed"),
constraint subs_UserSubscribed_key unique ("UserSubscribed")
) tablespace pg_default;
```
> Project was tested with RLS disabled on all tables