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

Unable to change recovery redirect #236

Open
buidles opened this issue Nov 18, 2023 · 1 comment
Open

Unable to change recovery redirect #236

buidles opened this issue Nov 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@buidles
Copy link

buidles commented Nov 18, 2023

Not sure if this is the best place to ask, apologies if not.

I need a bit of guidance in setting up the forgotten password functionality correctly. The forgotten password form sends an email which can be seen in Inbucket (I'm using a local installation of Supabase for development).

When I click on the link in the email the URL is http:https://localhost/auth/v1/verify?token=pkce_7ca51de7cf50d3aa016b59ca0a019609a0d46eb6c1c329138e2889e3&type=recovery&redirect_to=http:https://localhost:5173/

The first issue is that http:https://localhost/auth... should be http:https://localhost:54321/auth... - I don't think this is much of an issue though as I'm sure the correct url will be used once the hosted version of Supabase is used.

However what is important is being able to change the redirect URL - I need it to be the URL of where my update password form is which is http:https://localhost:5173/auth/update-password. Where can this be done?

Update

I should add that the redirectTo prop value is ignored.

Update

I have edited the config.toml file with the following values and restarted supabase - still the same issue though.

site_url = "http:https://localhost:5173"
additional_redirect_urls = ["http:https://localhost:5173/auth/callback","http:https://localhost:5173/auth/update-password"]

Update

The redirect issue has been solved - the value I was feeding to the prop was using a variable that was not actually outputting what I thought it was and was not an actual url so the root url was used.

The email link now contains the correct redirect url, however there is now a loop - I have an onAuthStateChange listening for SIGNED_IN event - when that happens the user is redirected to the home page. So when the user is automatically logged in after clicking the email link this event is triggered and the user is redirected to the home page instead of the redirect url.

From reading the docs it seems a PASSWORD_RECOVERY event should be fired - it isn't. Maybe this is a bug in my local Supabase. I think the only way forward with this is to make use of the hosted version and go from there. I have to say that the reason I opted to use Supabase was to make things easier, but setting up this auth is a pretty painful experience.

@buidles buidles added the bug Something isn't working label Nov 18, 2023
@P451M
Copy link

P451M commented Dec 24, 2023

I had the same problem(s) and just figured out that one can use the USER_UPDATED event:

supabase.auth.onAuthStateChange((event, newSession) => {
   if (event == "USER_UPDATED") router.push("/");
 });

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
None yet
Development

No branches or pull requests

2 participants