Guest User

Untitled

a guest
Oct 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. class PasswordResetsController < ApplicationController
  2. skip_before_filter :authenticate
  3. before_filter :load_user_using_perishable_token, :only => [:edit, :update]
  4. def create
  5. @user = User.find_by_email(params[:email])
  6. if @user
  7. @user.deliver_password_reset_instructions!
  8. redirect_to pw_success_url
  9. else
  10. redirect_to pw_failure_url
  11. end
  12. end
  13.  
  14. def update
  15. puts "*********Made it to update************"
  16. @user.password = params[:user][:password]
  17. @user.password_confirmation = params[:user][:password_confirmation]
  18. if @user.save
  19. redirect_to login_url
  20. else
  21. render :action => :edit
  22. end
  23. end
  24. private
  25. def load_user_using_perishable_token
  26. @user = User.find_using_perishable_token(params[:id])
  27. unless @user
  28. flash[:notice] = "We're sorry, but we could not locate your account. " +
  29. "If you are having issues try copying and pasting the URL " +
  30. "from your email into your browser or restarting the " +
  31. "reset password process."
  32. redirect_to login_url
  33. end
  34. end
  35. end
Add Comment
Please, Sign In to add comment