netlify-labs / react-netlify-identity

a tiny (4kb) React hook for using Netlify Identity, no UI. SEEKING MAINTAINERS
https://netlify-gotrue-in-react.netlify.com/
156 stars 25 forks source link

How to confirm user newly signed up? #40

Open dorelljames opened 4 years ago

dorelljames commented 4 years ago

In [gotrue-js] to confirm a user you have to take the user token and call:

auth.confirm(token, remember)

How do you do this in this library?

elijahsullivan commented 4 years ago

@dorelljames This should happen automatically with this library if you are using the context provider or hook. The runRoutes.tsx file parses the URL for a hash matching confirmation_token and calls the GoTrue instance's confirm method with the token found in the URL.

You can try this in a local development environment by using the signupUser function provided by the useIdentityContext with an email you control. Netlify should send a confirmation email to the email address you provided. Click on the link and it will navigate to YOUR_NETLIFY_URL/#confirmation_token=TOKEN. If you replace YOUR_NETLIFY_URL with the address of your locally hosted application (e.g. localhost:3000/) and load that URL in your browser, you should see that you are now logged in as that user.

Please let me know if this didn't answer your question or solve your problem and I can investigate more!

frednomoon commented 2 years ago

this seems now to be broken? im receiving a 422 response when visiting the confirm address.... any ideas?

{"code":422,"msg":"Invited users must specify a password"}
cmarabate commented 1 year ago

@dorelljames This should happen automatically with this library if you are using the context provider or hook. The runRoutes.tsx file parses the URL for a hash matching confirmation_token and calls the GoTrue instance's confirm method with the token found in the URL.

You can try this in a local development environment by using the signupUser function provided by the useIdentityContext with an email you control. Netlify should send a confirmation email to the email address you provided. Click on the link and it will navigate to YOUR_NETLIFY_URL/#confirmation_token=TOKEN. If you replace YOUR_NETLIFY_URL with the address of your locally hosted application (e.g. localhost:3000/) and load that URL in your browser, you should see that you are now logged in as that user.

Please let me know if this didn't answer your question or solve your problem and I can investigate more!

This no longer works it seems. I tried it on the live site and locally replacing the domain with the local domain but either way it did not log me in after visiting the link and it did not confirm the email address because when I try to login manually afterward it tells me that the email address has not been confirmed.