Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Feat(auth): Improve documentation + add localhost redirection

Anthony Rimet244e4bd6c40d
diff --git a/README.md b/README.md
index b11c326e..0104b5a0 100644
--- a/README.md
+++ b/README.md
@@ -110,14 +110,16 @@ GIT_USER_EMAIL: The deploy user's email
## Supabase
### Password Reset When Forgotten
-If users forgot their password, they can request for a reset. Atomic CRM handle it for you. All the magic is done by the custom route `/forgot-password` and `/reset-password` that you can find in the `CRM` component.
+If users forgot their password, they can request for a reset. Atomic CRM handle it for you. All the magic is done by the custom route `/forgot-password` and `/set-password` that you can find in the `CRM` component.
If you want to update default configuration:
+### Local development
+
1. Go to your `config.toml` file
2. In `[auth]` section set `site_url` to your application URL
3. In `[auth]`, add the following URL in the `additional_redirect_urls = [{APPLICATION_URL}}/auth-callback"]`
-4. Add an `[auth.email.templace.recovery]` section with the following option
+4. Add an `[auth.email.template.recovery]` section with the following option
```
[auth.email.template.recovery]
subject = "Reset Password"
@@ -132,4 +134,16 @@ In Recovery email template set the `auth-callback` redirection
<h2>Reset Password</h2>
<p><a href="{{ .ConfirmationURL }}/auth-callback">Reset your password</a></p>
</body>
-</html>
\ No newline at end of file
+</html>
+```
+
+Supabase provides an [Inbucket](https://inbucket.org/) instance that allows you to test your emails and configure your flow.
+
+### Production
+
+This requires you to configure your supabase instance:
+
+1. Go to your dashboard Authentication section
+2. In URL Configuration, set Site URL to your application URL
+3. In URL Configuration, add the following URL in the Redirect URLs section: `YOUR_APPLICATION_URL/auth-callback`
+4. In Email Templates, change the `"{{ .ConfirmationURL }}"` to `"{{ .ConfirmationURL }}/auth-callback"`
\ No newline at end of file
diff --git a/supabase/config.toml b/supabase/config.toml
index dce32d94..4f8f1153 100644
--- a/supabase/config.toml
+++ b/supabase/config.toml
@@ -69,9 +69,9 @@ file_size_limit = "50MiB"
enabled = true
# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
# in emails.
-site_url = "http://127.0.0.1:5173"
+site_url = "http://localhost:5173/"
# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
-additional_redirect_urls = ["https://127.0.0.1:5173/auth-callback"]
+additional_redirect_urls = ["https://localhost:5173/auth-callback"]
# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week).
jwt_expiry = 3600
# If disabled, the refresh token will never expire.
diff --git a/supabase/templates/recovery.html b/supabase/templates/recovery.html
index 611f8ce4..8e9c72ac 100644
--- a/supabase/templates/recovery.html
+++ b/supabase/templates/recovery.html
@@ -60,7 +60,7 @@
<div class="content">
<p>Hello,</p>
<p>To reset your password, follow the link below:</p>
- <a href="{{ .ConfirmationURL }}/auth-callback" class="button"
+ <a href="{{ .ConfirmationURL }}auth-callback" class="button"
>Reset my password</a
>
<p>