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

Signup confirmation email link buggy on second click #504

Closed
laurentS opened this issue Jan 10, 2021 · 15 comments
Closed

Signup confirmation email link buggy on second click #504

laurentS opened this issue Jan 10, 2021 · 15 comments
Labels
bug Something isn't working
Projects

Comments

@laurentS
Copy link

Bug report

Describe the bug

if I click the account confirmation link again after confirming, I get an ugly JSON 404 response. Since this is user facing, it can be confusing.
The JSON response looks like this {"code":404,"msg":"User not found"}.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. signup as a user of a supabase app (triggered by supabase.auth.signup())
  2. open confirmation email and click the link, and find yourself in the app as expected
  3. go back to mailbox and click the link again (say I forgot if I clicked it or not)
  4. end up on the error message above

Expected behavior

A proper HTML page with a meaningful message would be better. Maybe "you've already confirmed your account"?

@laurentS laurentS added the bug Something isn't working label Jan 10, 2021
@carlosstenzel
Copy link
Contributor

use

const { data, error } = await supabase.auth.signUp({
    email: email,
    password: password,
  });

  if (error) {
    toast.error(error.message, {
      position: toast.POSITION.TOP_RIGHT,
    });
    return false;
  }

and

const { error } = await supabase.auth.signIn({
    email: email,
    password: password,
  });

  if (error) {
    toast.error(error.message, {
      position: toast.POSITION.TOP_RIGHT,
    });
  }

in https://app.supabase.io/project//auth/settings config the field Site URL

and everything will work :D

@laurentS
Copy link
Author

@carlosstenzel Thanks for sharing these, and sorry for not replying earlier. Unfortunately, I don't think these address my issue. I have configured the site url in settings, and everything works fine from clicking the signup confirmation link in the email until I'm back in my app. The email has a link like https://<app_id>.supabase.co/auth/v1/verify?token=<the_token>&type=signup. My error happens after clicking this link (a second time), not at the initial call to supabase.auth.signUp.
Is there something else I'm missing?

@carlosstenzel
Copy link
Contributor

understand

double clicking to confirm it returns the error.

{"code":404,"msg":"User not found"}

@kiwicopple . can we make a lake to deal with this error?

** if the token does not exist, just redirect to the site

@laurentS
Copy link
Author

I was just looking at the code in gotrue to understand what is happening. I don't speak Go, but it seems that this line is where the issue is. I'm seeing a 404 JSON, but maybe a more user friendly page that shows HTML instead of JSON would be easier. Or redirect to the siteURL with an extra param so we can handle it in the app.

@laurentS
Copy link
Author

laurentS commented Feb 6, 2021

Just found this other issue which seems to be the same

@awalias
Copy link
Member

awalias commented Mar 10, 2021

ah! looks like we applied the fix only to recovery and not to signup: https://github.com/supabase/gotrue/pull/44/files

@AngeloAnolin
Copy link
Contributor

Attempt to fix via https://github.com/supabase/gotrue/pull/82

Sorry had to put the comment here as the fix was made in the gotrue repo but the issue is in this supabase repo.

@tylermercer
Copy link

What is the status on this? The PRs mentioned above were merged but it still happens.

@janzheng
Copy link

janzheng commented May 9, 2021

Is it possible to handle stale magic links w/ a redirect URL, e.g. to a signup page?

@awalias
Copy link
Member

awalias commented Sep 22, 2021

appears to be fixed now, I get redirected to "<SITE_URL>/#error_code=404&error_description=Confirmation+Token+not+found"

@awalias awalias closed this as completed Sep 22, 2021
@peachp
Copy link

peachp commented Mar 10, 2023

@awalias I see it's closed, but since this is the only place I found when googling, for benefit of others:

When clicking on the {{ .ConfirmationURL }} second time from email, user gets redirected to an URL which includes:

#error=unauthorized_client&error_code=401&error_description=Email+link+is+invalid+or+has+expired

Now I didn't test how it looks when you click on it when it's actually expired*. The error_description says "invalid+or+has+expired", so I wonder how do I know which one it is? Because I need to show different things to the user. (Unless you can advise me if I need to do it, it's a smell that my auth flow is bad...?)

*Btw, is this controlled by
Auth settings > User Sessions > JWT expiry limit
?

@chrisguerrero
Copy link

chrisguerrero commented Apr 6, 2023

+1. Wondering what the preferred method of handling auth errors for an expired magic link is.

@Chippd
Copy link

Chippd commented Apr 23, 2023

+1 I'm in the same boat as @peachp. I don't know if my auth flow is bad or what, I'm getting multiple reports of users being put in an endless loop where the magic links they're clicking from email are expired. This is also the only place I found via Google that mentions this.

@AdamBCo
Copy link

AdamBCo commented Jun 28, 2023

+1

@xEverth
Copy link

xEverth commented Dec 21, 2023

Also had some users report this issue. I'm trying to see if it's an email security setting that "clicks" on the links before the users are able to. Any updates from the team as how to handle invalid confirmation links?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Tools
Triage
Development

No branches or pull requests