Skip to content

Commit 44441b7

Browse files
committed
docs: add README to user management example
1 parent ef58291 commit 44441b7

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Examples/UserManagement/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Supabase Swift User Management
2+
3+
This repo is a quick sample of how you can get started building apps using Swift and Supabase. You can find a step by step guide of how to build out this app in the [Quickstart: Swift guide](https://supabase.io/docs/guides/with-swift).
4+
5+
This repo will demonstrate how to:
6+
- Sign users in with Supabase Auth using [magic link](https://supabase.io/docs/reference/dart/auth-signin#sign-in-with-magic-link)
7+
- Store and retrieve data with [Supabase database](https://supabase.io/docs/guides/database)
8+
- Store image files in [Supabase storage](https://supabase.io/docs/guides/storage)
9+
10+
![Supabase User Management example](supabase-swift-demo.png)
11+
12+
## Getting Started
13+
14+
Before running this app, you need to create a Supabase project and copy [your credentials](https://supabase.io/docs/guides/with-flutter#get-the-api-keys) to `Supabase.swift`.
15+
16+
Run the application in a device or simulator using Xcode.
17+
18+
## Database Schema
19+
20+
```sql
21+
-- Create a table for public "profiles"
22+
create table profiles (
23+
id uuid references auth.users not null,
24+
updated_at timestamp with time zone,
25+
username text unique,
26+
avatar_url text,
27+
website text,
28+
29+
primary key (id),
30+
unique(username),
31+
constraint username_length check (char_length(username) >= 3)
32+
);
33+
34+
alter table profiles enable row level security;
35+
36+
create policy "Public profiles are viewable by everyone."
37+
on profiles for select
38+
using ( true );
39+
40+
create policy "Users can insert their own profile."
41+
on profiles for insert
42+
with check ( auth.uid() = id );
43+
44+
create policy "Users can update own profile."
45+
on profiles for update
46+
using ( auth.uid() = id );
47+
48+
-- Set up Realtime!
49+
begin;
50+
drop publication if exists supabase_realtime;
51+
create publication supabase_realtime;
52+
commit;
53+
alter publication supabase_realtime add table profiles;
54+
55+
-- Set up Storage!
56+
insert into storage.buckets (id, name)
57+
values ('avatars', 'avatars');
58+
59+
create policy "Avatar images are publicly accessible."
60+
on storage.objects for select
61+
using ( bucket_id = 'avatars' );
62+
63+
create policy "Anyone can upload an avatar."
64+
on storage.objects for insert
65+
with check ( bucket_id = 'avatars' );
66+
```
75.1 KB
Loading

0 commit comments

Comments
 (0)