Guest User

Untitled

a guest
Jul 2nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. def forgot_password
  2. return unless request.post?
  3. @user = User.find_by_email(params[:user][:email])
  4. @forgotten_password = true
  5.  
  6. @reset = @user.make_password_reset_code
  7. flash[:not] = @reset
  8.  
  9. @user.password_reset_code = @reset
  10. @user.update_attributes(params[:password_reset_code])
  11.  
  12. if @user.save
  13. UserMailer.deliver_forgot_password(@user)
  14.  
  15. redirect_back_or_default('/')
  16. flash[:notice] = "A password reset link has been sent to your email address"
  17. # end
  18. else
  19. flash[:alert11] = "Could not find a user with that email address"
  20. exit
  21. end
  22. end
Add Comment
Please, Sign In to add comment