Skip to content

Commit 1431ee8

Browse files
authored
docs: Clarify email prefetch options (supabase#40034)
* docs: Clarify email prefetch options * use relative url * prettier
1 parent 315a39d commit 1431ee8

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

apps/docs/content/guides/auth/auth-email-templates.mdx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,34 @@ For mobile applications, you might need to link or redirect to a specific page w
7171

7272
Certain email providers may have spam detection or other security features that prefetch URL links from incoming emails (e.g. [Safe Links in Microsoft Defender for Office 365](https://learn.microsoft.com/en-us/microsoft-365/security/office-365-security/safe-links-about?view=o365-worldwide)).
7373
In this scenario, the `{{ .ConfirmationURL }}` sent will be consumed instantly which leads to a "Token has expired or is invalid" error.
74-
To guard against this:
74+
To guard against this there are the options below:
7575

76-
- Use an email OTP instead by including `{{ .Token }}` in the email template.
77-
- Create your own custom email link to redirect the user to a page where they can click on a button to confirm the action.
78-
For example, you can include the following in your email template:
76+
**Option 1**
7977

80-
```html
81-
<a href="{{ .SiteURL }}/confirm-signup?confirmation_url={{ .ConfirmationURL }}"
82-
>Confirm your signup
83-
</a>
84-
```
78+
- Use an email OTP instead by including `{{ .Token }}` in the email template
79+
- Create your own custom email link to redirect the user to a page where they can enter with their email and token to login
8580

86-
The user should be brought to a page on your site where they can confirm the action by clicking a button.
87-
The button should contain the actual confirmation link which can be obtained from parsing the `confirmation_url={{ .ConfirmationURL }}` query parameter in the URL.
81+
```html
82+
<a href="{{ .SiteURL }}/confirm-signup">Confirm your signup</a>
83+
```
84+
85+
- Log them in by verifying the OTP token value with their email e.g. with [`supabase.auth.verifyOtp`](/docs/reference/javascript/auth-verifyotp) show below
86+
87+
```ts
88+
const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'email' })
89+
```
90+
91+
**Option 2**
92+
93+
- Create your own custom email link to redirect the user to a page where they can click on a button to confirm the action
94+
95+
```html
96+
<a href="{{ .SiteURL }}/confirm-signup?confirmation_url={{ .ConfirmationURL }}"
97+
>Confirm your signup</a
98+
>
99+
```
100+
101+
- The button should contain the actual confirmation link which can be obtained from parsing the `confirmation_url={{ .ConfirmationURL }}` query parameter in the URL.
88102

89103
### Email tracking
90104

0 commit comments

Comments
 (0)