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 #12

Closed
aarondmills opened this issue Dec 21, 2011 · 5 comments
Closed

Password Reset #12

aarondmills opened this issue Dec 21, 2011 · 5 comments

Comments

@aarondmills
Copy link

I have attempted to create a password reset process for users that make a mistake on signup, or forget their password. It seems though that simply updating the attributes of the identity model where the password is stored does not work.

Does anyone have a good solution for this?

@mrnbrkt
Copy link

mrnbrkt commented Jan 17, 2012

Are you setting the password_confirmation field too?

Assuming you are resetting the password programmatically and not in a form, you have to take care of that instead of the user, Otherwise changes will not be saved to database as validation of password confirmation will fail.

@daidekman
Copy link

Aaron - I have the same question. I've used the railscasts to setup omniauth-identity which works great. Then I've tried the railscast for password reset, but I know that the controller and form aren't right to update the identity model and change the password. Were you able to find a solution for this? Any help is most welcome!

@wdspkr
Copy link

wdspkr commented Feb 20, 2012

Once you understand that omniauth-identity is using ActiveModel's SecurePassword it's really easy to solve this.
Instead of setting the password_digest you just set password and password_confirmation and update.
Like so:

@identity = Identity.find(1)
@identity.password = "newpassword"
@identity.password_confirmation = "newpassword"
@identity.save

@mrnbrkt
Copy link

mrnbrkt commented Feb 20, 2012

Yep, just like I said :)

@pboling
Copy link
Member

pboling commented Feb 14, 2021

@identity = Identity.find(1)
@identity.password = "newpassword"
@identity.password_confirmation = "newpassword"
@identity.save

Should work. Closing. If still an issue please write a failing spec!

@pboling pboling closed this as completed Feb 14, 2021
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

5 participants