Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Email template MailType variable #22013

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions apps/docs/content/guides/auth/auth-email-templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The templating system provides the following variables for use:
| `{{ .SiteURL }}` | Contains your application's Site URL. This can be configured in your project's [authentication settings](/dashboard/project/_/auth/url-configuration). |
| `{{ .RedirectTo }}` | Contains the redirect URL passed when `signUp`, `signInWithOtp`, `signInWithOAuth`, `resetPasswordForEmail` or `inviteUserByEmail` is called. The redirect URL allow list can be configured in your project's [authentication settings](/dashboard/project/_/auth/url-configuration). |
| `{{ .Data }}` | Contains metadata from `auth.users.user_metadata`. Use this to personalize the email message. |
| `{{ .MailType }}` | Contains the email type being sent. This will be one of: `magiclink`, `recovery`, `invite`, `signup` or `email_change`. |

## Limitations

Expand Down
19 changes: 18 additions & 1 deletion apps/docs/content/guides/cli/customizing-email-templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Contains a hashed version of the `Token`. This is useful for constructing your o
```html
<p>Follow this link to confirm your user:</p>
<p>
<a href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=email"
<a href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type={{ .MailType }}"
>Confirm your email</a
>
</p>
Expand Down Expand Up @@ -113,6 +113,23 @@ Contains the new user's email address. This is only available in the `email_chan
<p>You are requesting to update your email address to {{ .NewEmail }}.</p>
```


### MailType

Contains the MailType being sent.

The value will be one of: `magiclink`, `recovery`, `invite`, `signup` or `email_change`.

**Usage**

```html
<p>
<a href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type={{ .MailType }}"
>Click the Link</a
>
</p>
```

## Deploying email templates

These settings are for local development. To apply the changes locally, stop and restart the Supabase containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const CONFIRMATION: FormSchema = {
- \`{{ .SiteURL }}\` : The URL of the site
- \`{{ .Email }}\` : The user's email address
- \`{{ .Data }}\` : The user's \`user_metadata\`
- \`{{ .MailType }}\`: The type of email being sent.
- \`{{ .RedirectTo }}\` : The URL of \`emailRedirectTo\` passed in options
`,
},
Expand Down Expand Up @@ -59,6 +60,7 @@ const INVITE: FormSchema = {
- \`{{ .SiteURL }}\` : The URL of the site
- \`{{ .Email }}\` : The user's email address
- \`{{ .Data }}\` : The user's \`user_metadata\`
- \`{{ .MailType }}\`: The type of email being sent.
- \`{{ .RedirectTo }}\` : The URL of \`redirectTo\` passed in options
`,
},
Expand Down Expand Up @@ -94,6 +96,7 @@ const MAGIC_LINK: FormSchema = {
- \`{{ .SiteURL }}\` : The URL of the site
- \`{{ .Email }}\` : The user's email address
- \`{{ .Data }}\` : The user's \`user_metadata\`
- \`{{ .MailType }}\`: The type of email being sent.
- \`{{ .RedirectTo }}\` : The URL of \`emailRedirectTo\` passed in options
`,
},
Expand Down Expand Up @@ -130,6 +133,7 @@ const EMAIL_CHANGE: FormSchema = {
- \`{{ .Email }}\` : The original user's email address
- \`{{ .NewEmail }}\` : The user's new email address
- \`{{ .Data }}\` : The user's \`user_metadata\`
- \`{{ .MailType }}\`: The type of email being sent.
- \`{{ .RedirectTo }}\` : The URL of \`emailRedirectTo\` passed in options
`,
},
Expand Down Expand Up @@ -165,6 +169,7 @@ const RECOVERY: FormSchema = {
- \`{{ .SiteURL }}\` : The URL of the site
- \`{{ .Email }}\` : The user's email address
- \`{{ .Data }}\` : The user's \`user_metadata\`
- \`{{ .MailType }}\`: The type of email being sent.
- \`{{ .RedirectTo }}\` : The URL of \`redirectTo\` passed in options
`,
},
Expand Down