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

Password Reset Link params without POST /password #1070

Closed
wmlutz opened this issue Jan 18, 2018 · 6 comments
Closed

Password Reset Link params without POST /password #1070

wmlutz opened this issue Jan 18, 2018 · 6 comments

Comments

@wmlutz
Copy link

wmlutz commented Jan 18, 2018

I am running a Rails API, doing a lot of email branding with SendGrid, and am trying to not use ActionMailer. Therefore I want to do the password reset 'manually.' I.e. not using the POST /password endpoint which uses ActionMailer.

To do it manually a couple of things need to happen: I want to generate a url with query params to pass to my SendGrid API. This will be a link to the page that takes password and password_confirmation. That link needs to have query params with the proper authentication info which will then be put in the header the password and confirmation are sent.

A password reset token seems to not be a problem with @resource.reset_password_token which will be in the PUT header at access-token. Uid is fine too. But client and expiry for that token, I can't figure out how to get in @resource's controller.

Help appreciated.

@zachfeldman
Copy link
Contributor

@wmlutz I don't think you need a client and expiry token, just a password reset token, to reset the password. That token services as authentication.

@wmlutz
Copy link
Author

wmlutz commented Jan 18, 2018

@zachfeldman I'm still having troubles. Going into console I grab a password reset token and tested with this curl req:

curl -X PUT -H "access-token: 5552bf8e986f87420267080de6d16b845a8a52750fa07e04d2dc6e76b3dc9d33" http://localhost:3001/api/v1/auth/password?password=newpass&password_confirmation=newpass

But am getting {"success":false,"errors":["Unauthorized"]} in response

I admittedly am not the best or most experienced guy in the room - can you tell what I'm missing?

@zachfeldman
Copy link
Contributor

I'm using the jToker implementation for my app:

@zachfeldman
Copy link
Contributor

https://github.com/lynndylanhurley/j-toker/blob/master/src/j-toker.js#L1033

Looks like I need to send password, password confirmation, email, and reset_password_token.

@lynndylanhurley
Copy link
Owner

lynndylanhurley commented Jan 18, 2018

@wmlutz

  1. start by sending a POST request to the /auth/password endpoint containing the email address for the account and a redirect_url to which the user should be redirected to after the API validates the password reset token.

  2. The API will send a link to the email address used for signup that contains a link with the auth creds as querystring params. Once the client visits that link, they will be confirmed by the API using the reset_password_token and redirected to the client at the redirect_url provided in step 1.

  3. Once the user is authenticated by the API, they can then reset their password from the client using the PUT /auth/password endpoint and the creds that were passed to the client by the API redirect.

@wmlutz
Copy link
Author

wmlutz commented Jan 18, 2018

@lynndylanhurley What I'm trying to do is skip this part:

The API will send a link to the email address
So I can use my own email API to manage all the app's communications.

I figured out what I need to do though to do this manually. It's basically following build_auth_header from https://github.com/lynndylanhurley/devise_token_auth#model-concerns at my own API endpoint. Got it working via curl now.

@wmlutz wmlutz closed this as completed Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants