Hi Supabase team, we use `auth.signInWithOtp`/`verifyOtp` and set `user_metadata.source` to `"website"` at signup. We need to change that field to `"portal"` when the same user later signs in through our portal so email templates can branch on `source`.
Questions:
- Is there a recommended or official way to ensure `user_metadata` is refreshed per-login so a user who signed up on the website can log in via the portal and have `source` switch to `"portal"`?
- Any best practices or constraints we should follow to allow for this behavior so our emails can change UI based on where our user is logging in from?
# Context
When our user logs into our portal, we ONLY want to send the OTP code email UI. When they login via our website, we want the URL we use with stable token hash for URL redirection.
# Email Template
Confirm your email - Finatic
Confirm your email to get started
|
{{ if eq .Data.source "portal" }}
Enter this code in the portal window:
{{ .Token }}
No redirect needed. Keep this email open until you finish.
{{ else }}
You're almost there! Click the button below to finish confirming your email.
Or use this code if the link does not work: {{ .Token }}
{{ end }}
.Data (raw): {{ .Data }}
.Data.source: {{ .Data.source }}
.RedirectTo: {{ .RedirectTo }}
.SiteURL: {{ .SiteURL }}
.Email: {{ .Email }}
....
| | |