Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0a4d54c
wip: minor fizes needed, compile time issues on injecting macro codes
zoedsoupe Sep 24, 2024
c017d33
wip: quickstarts
zoedsoupe Sep 24, 2024
787395b
some fixes
zoedsoupe Oct 26, 2024
c59b7cd
fix: ex_doc linkings
zoedsoupe Jan 14, 2025
2262f9d
improved dev env
zoedsoupe Mar 5, 2025
8e84c85
issue 57
zoedsoupe Mar 5, 2025
4fb0bea
Merge branch 'main' into setup/improved-dev-env
zoedsoupe Mar 5, 2025
d16c3c1
Merge branch 'main' into setup/improved-dev-env
zoedsoupe May 2, 2025
dd9c8cc
Merge branch 'main' into fix/docs-linking
zoedsoupe May 2, 2025
e231d65
fix: missing api key header on requests
zoedsoupe May 6, 2025
979a0e7
fix: supaabse start was failing
zoedsoupe May 17, 2025
fa7f4ae
Merge branch 'setup/improved-dev-env' into feat/release-0.6.2
zoedsoupe May 19, 2025
5260c83
Merge branch 'fix/missing-api-key' into feat/release-0.6.2
zoedsoupe May 19, 2025
9547790
capture logs on tests
zoedsoupe May 19, 2025
5aa676e
Merge branch 'feat/release-0.6.2' into feat/examples
zoedsoupe May 21, 2025
52a5c04
reset example app initial scaffold
zoedsoupe May 21, 2025
e19061e
basic supabase-ex setup
zoedsoupe May 21, 2025
93bd5ff
rename typo folder
zoedsoupe May 21, 2025
3c52a97
Configure Supabase integration with auth module
zoedsoupe May 21, 2025
012b06d
feat: generate live view with supabase-gotrue
zoedsoupe May 21, 2025
0fa10d2
Create migrations for profiles and storage buckets
zoedsoupe May 21, 2025
cca66a2
Add profiles context and schema
zoedsoupe May 21, 2025
cbb429b
Customize Auth and add profile creation on login
zoedsoupe May 21, 2025
4a90340
Update login flow to use only magic links
zoedsoupe May 21, 2025
c6dd46d
Add profile page with avatar upload support
zoedsoupe May 21, 2025
b23f507
Update CSS styling and layouts to match Nuxt version
zoedsoupe May 21, 2025
59946fb
Add Supabase project configuration
zoedsoupe May 21, 2025
14b1477
minimal usable version, have bugfixes
zoedsoupe May 21, 2025
9e6aab8
Merge branch 'main' into feat/examples
zoedsoupe Jun 29, 2025
c9f4fbc
chore: correct pattern matching
zoedsoupe Jun 29, 2025
9cdaef1
wip: fixes to a working example
zoedsoupe Jun 30, 2025
2249d67
wip: more minor fixes for a working example
zoedsoupe Jun 30, 2025
cbaf59d
Merge branch 'main' into feat/examples
zoedsoupe Jul 20, 2025
f9c830a
wip
zoedsoupe Jul 20, 2025
ac1ed9f
chore: minor fixes
zoedsoupe Jul 20, 2025
1a2683b
Merge branch 'main' into feat/examples
zoedsoupe Jul 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ export ERL_AFLAGS="-kernel shell_history enabled"

export LANG=en_US.UTF-8

if [ -f .env.dev ]; then
source .env.dev
fi

use flake
6 changes: 6 additions & 0 deletions examples/user_management/.formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
import_deps: [:ecto, :ecto_sql, :phoenix],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
]
36 changes: 36 additions & 0 deletions examples/user_management/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Temporary files, for example, from tests.
/tmp/

# Ignore package tarball (built via "mix hex.build").
user_management-*.tar

# Ignore assets that are produced by build tools.
/priv/static/assets/

# Ignore digested assets cache.
/priv/static/cache_manifest.json

# In case you use Node.js/npm, you want to ignore these.
npm-debug.log
/assets/node_modules/
93 changes: 93 additions & 0 deletions examples/user_management/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Supabase Phoenix User Management

This example demonstrates how to build a user management application using Phoenix LiveView and Supabase. It's a Phoenix port of the [Nuxt 3 User Management example](https://github.com/supabase/supabase/tree/master/examples/user-management/nuxt3-user-management).

## Features

This example shows how to:

- Sign users in with Supabase Auth using [magic link](https://supabase.io/docs/reference/dart/auth-signin#sign-in-with-magic-link)
- Store and retrieve user profile data with [Supabase database](https://supabase.io/docs/guides/database)
- Upload and display avatar images using [Supabase storage](https://supabase.io/docs/guides/storage)
- Protect routes with Phoenix authentication

## Getting Started

Before running this app, you need to create a Supabase project and set up your environment variables.

1. Create a Supabase project
2. Copy your Supabase URL and API key from the project settings
3. Set environment variables:

```bash
export SUPABASE_URL=https://your-project.supabase.co
export SUPABASE_KEY=your-anon-key
```

4. Install dependencies and setup the database:

```bash
mix setup
```

5. Start the Phoenix server:

```bash
mix phx.server
```

Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.

## Database Schema

The example uses the following database schema for user profiles and storage:

```sql
-- Create a table for public "profiles"
create table profiles (
id uuid primary key,
user_id uuid not null,
username text,
website text,
avatar_url text,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null,
updated_at timestamp with time zone default timezone('utc'::text, now()) not null
);

alter table profiles enable row level security;

create policy "Public profiles are viewable by everyone."
on profiles for select
using ( true );

create policy "Users can insert their own profile."
on profiles for insert
with check ( auth.uid() = user_id );

create policy "Users can update own profile."
on profiles for update
using ( auth.uid() = user_id );

-- Set up Storage
insert into storage.buckets (id, name)
values ('avatars', 'avatars');

create policy "Avatar images are publicly accessible."
on storage.objects for select
using ( bucket_id = 'avatars' );

create policy "Anyone can upload an avatar."
on storage.objects for insert
with check ( bucket_id = 'avatars' );
```

## Implementation Notes

This example uses:

- [Phoenix LiveView](https://hexdocs.pm/phoenix_live_view) for interactive UI
- [Supabase Auth (GoTrue)](https://github.com/zoedsoupe/supabase-ex/tree/main/auth-ex) for authentication
- [Supabase Storage](https://github.com/zoedsoupe/supabase-ex/tree/main/storage-ex) for file uploads
- [Supabase Database](https://github.com/zoedsoupe/supabase-ex) for data access through Ecto

Authentication is implemented using magic links (email OTP) with the help of the `supabase.gen.auth` mix task from the `auth-ex` package.
Loading