auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

Added options with redirectTo for user update

Open mghizzo opened this issue 3 years ago • 2 comments

What kind of change does this PR introduce?

Accept options object with redirectTo and send it as a query parameter to the endpoint.

What is the current behavior?

While GoTrue accepts a query parameter for url redirect, there is no way to set it inside gotrue-js. It's probably not the best solution, it may be better to create a different method for user email change, as mentioned in the issue.

What is the new behavior?

Accept options object with redirectTo and send it as a query parameter to the endpoint.

Additional context

Look at this issue

mghizzo avatar Aug 22 '22 21:08 mghizzo

Hey @atzmanuel, thanks for flagging this out! this would need some fixing on gotrue's PUT /user endpoint since i would prefer to name the redirect_to param to something more explicit so it's clear that it will only apply to a user email update.

kangmingtay avatar Aug 24 '22 13:08 kangmingtay

Hey @atzmanuel, thanks for flagging this out! this would need some fixing on gotrue's PUT /user endpoint since i would prefer to name the redirect_to param to something more explicit so it's clear that it will only apply to a user email update.

Hey @kangmingtay, thanks for your reply. I understand that it's not clear that it will apply only to email change but, I don't think that renaming parameter on gotrue's endpoint is possible since it uses a global API method called getReferrer which is shared across the project. An alternative solution may be creating another method like changeEmail which accept redirectTo param and leave update() method as it is. The method changeEmail will require a mandatory parameter newEmail and an optional redirectTo parameter and will fire the same PUT /user endpoint. Let me know what do you think about this solution.

mghizzo avatar Aug 24 '22 14:08 mghizzo

Is there any reason this can't be pushed through with one of the various solutions? It doesn't seem like a big change to make and even editing the docs would be trivial. Gotrue has this functionality built in.

elliott44k avatar Oct 06 '22 06:10 elliott44k

Closing this one out as this was fixed in supabase/gotrue#610.

silentworks avatar Apr 03 '23 22:04 silentworks

@silentworks I may be mistaken, but the pull request was about "Remove system user" and there is no mention to redirect in that PR's commit, is it really fixed?

JonathanPicques avatar Apr 11 '23 10:04 JonathanPicques

@JonathanPicques i think @silentworks was referring to this PR instead: https://github.com/supabase/gotrue-js/pull/610

kangmingtay avatar Apr 11 '23 13:04 kangmingtay