From 71f11abe31d07e4a90d8b321f8534784e6745b82 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kaiser Date: Wed, 23 Oct 2024 16:12:27 +0200 Subject: [PATCH] [Demo] Configure local Supabase instance to support invitation and password reset out of the box --- README.md | 6 ++---- packages/ra-supabase/README.md | 10 +++++----- supabase/config.toml | 8 ++++++++ supabase/templates/invite.html | 7 +++++++ supabase/templates/recovery.html | 6 ++++++ 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 supabase/templates/invite.html create mode 100644 supabase/templates/recovery.html diff --git a/README.md b/README.md index 09545ae..819e7c1 100644 --- a/README.md +++ b/README.md @@ -59,11 +59,9 @@ If you need debug the backend, you can access the following services: ### Testing Invitations And Password Reset -The current version of supabase CLI does not allow to customize the emails sent for invitation or password reset. +When you invite a new user through the [Authentication dashboard](http://localhost:54323/project/default/auth/users), or reset a password through the [password reset form](http://localhost:8000/forgot-password), you can see the email sent in [Inbucket](http://localhost:54324/monitor). -When you invite a new user through the [Authentication dashboard](http://localhost:54323/project/default/auth/users), you can see the email sent in [Inbucket](http://localhost:54324/monitor). Instead of clicking the link, copy it and change the `redirect_to` parameter from `http://localhost:8000` to `http://localhost:8000/auth-callback`. - -Apply the same process for password reset emails. +Clicking the link inside the email will take you to the `/set-password` page where you can set or reset your password. ### Testing Third Party Authentication Providers diff --git a/packages/ra-supabase/README.md b/packages/ra-supabase/README.md index ff12f4a..9098f94 100644 --- a/packages/ra-supabase/README.md +++ b/packages/ra-supabase/README.md @@ -257,9 +257,9 @@ In `{TYPE}.html` set the `auth-callback` redirection ```HTML -

{TYPE_MESSAGE}

+

{TYPE_MESSAGE}

{TYPE_CTA}

- + ``` @@ -336,14 +336,14 @@ In `invite.html` set the `auth-callback` redirection ```HTML -

You have been invited

+

You have been invited

You have been invited to create a user on {{ .SiteURL }}. Follow this link to accept the invite:

Accept the invite

- + ``` -### Configuring an hosted Supabase instance +#### Configuring an hosted Supabase instance 1. Go to your dashboard **Authentication** section 1. In **URL Configuration**, set **Site URL** to your application URL diff --git a/supabase/config.toml b/supabase/config.toml index 3ea5f2b..adc5f52 100644 --- a/supabase/config.toml +++ b/supabase/config.toml @@ -58,6 +58,14 @@ double_confirm_changes = true # If enabled, users need to confirm their email address before signing in. enable_confirmations = false +[auth.email.template.invite] +subject = "You have been invited" +content_path = "./supabase/templates/invite.html" + +[auth.email.template.recovery] +subject = "Reset Password" +content_path = "./supabase/templates/recovery.html" + # Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`, # `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin`, `notion`, `twitch`, # `twitter`, `slack`, `spotify`, `workos`, `zoom`. diff --git a/supabase/templates/invite.html b/supabase/templates/invite.html new file mode 100644 index 0000000..0785070 --- /dev/null +++ b/supabase/templates/invite.html @@ -0,0 +1,7 @@ + + +

You have been invited

+

You have been invited to create a user on {{ .SiteURL }}. Follow this link to accept the invite:

+

Accept the invite

+ + \ No newline at end of file diff --git a/supabase/templates/recovery.html b/supabase/templates/recovery.html new file mode 100644 index 0000000..3999f7b --- /dev/null +++ b/supabase/templates/recovery.html @@ -0,0 +1,6 @@ + + +

Reset Password

+

Reset your password

+ + \ No newline at end of file