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

refactor: add access to token used for magic-link generation #707

Merged
merged 2 commits into from
Nov 9, 2022

Conversation

hf
Copy link
Contributor

@hf hf commented Sep 27, 2022

Magic links often need to be customized. This PR allows folks to customize the link by providing access to the HashedToken.

EDIT: We changed this to use {{ .TokenHash }} instead. You can add this in your email templates in the Supabase dashboard under the email templating section
image

@hf hf requested a review from a team as a code owner September 27, 2022 17:13
Copy link
Member

@kangmingtay kangmingtay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed internally, we're gonna add {{ .HashedToken }} {{ .TokenHash }} in the go template and document how to use it in the email templates section in the UI

@hf hf force-pushed the hf/add-access-to-magic-link branch 2 times, most recently from c111d8f to e12c0a1 Compare October 19, 2022 16:23
@hf hf requested a review from kangmingtay October 19, 2022 16:23
@hf hf force-pushed the hf/add-access-to-magic-link branch from e12c0a1 to 9c25298 Compare November 2, 2022 11:01
@hf hf requested a review from a team November 2, 2022 11:02
@hf hf dismissed kangmingtay’s stale review November 2, 2022 11:02

Can you re-review?

@kangmingtay
Copy link
Member

hmm can you also add it to the RecoveryMail, InviteMail, EmailChangeMail and ConfirmationMail?

@kangmingtay kangmingtay merged commit 5959cb7 into master Nov 9, 2022
@kangmingtay kangmingtay deleted the hf/add-access-to-magic-link branch November 9, 2022 18:26
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

🎉 This PR is included in version 2.30.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@liaujianjie
Copy link

Is there documentation on how to use this feature on the client-side?

@kangmingtay
Copy link
Member

kangmingtay commented Dec 9, 2022

@liaujianjie we haven't updated our docs yet but you can start using it to circumvent the problem where email clients preview the magiclink in the email. This can be done by adding a link in the email template which redirects a user to a page on your site that contains a button that they need to click to "confirm their email". (i.e. <a href="https://your_site_url/confirm_signup?token={{.TokenHash}}&type=signup">Click here to confirm your email!</a>).

When the user clicks on that, they should be redirect to https://your_site_url/confirm_signup where you can grab the query params, reconstruct the actual verify endpoint: https://project_ref.supabase.co/auth/v1/verify?token={{.TokenHash}}&type=signup&redirect_to=xxx and embed the verify link in a button.

@liaujianjie
Copy link

@kangmingtay

  1. One small quality-of-life improvement suggestion: allow us to reference the site URL in the email templates so that we can construct the URL like <a href="{{.SiteUrl}}/confirm_signup?token={{.TokenHash}}">
    image
  2. How will redirection work with the use of .TokenHash?

@kangmingtay
Copy link
Member

Just checked, actually the site url is already available if you do {{ .SiteURL }}.

How will redirection work with the use of .TokenHash?

Hmm yeah i'll add this to the email templates too so it can be easily referenced. For now, the only way to get it is through the {{ .ConfirmationURL }} which isn't great..

uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
…e#707)

Magic links often need to be customized. This PR allows folks to
customize the link by providing access to the `HashedToken`.

Co-authored-by: Kang Ming <kang.ming1996@gmail.com>
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
…e#707)

Magic links often need to be customized. This PR allows folks to
customize the link by providing access to the `HashedToken`.

Co-authored-by: Kang Ming <kang.ming1996@gmail.com>
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
…e#707)

Magic links often need to be customized. This PR allows folks to
customize the link by providing access to the `HashedToken`.

Co-authored-by: Kang Ming <kang.ming1996@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants