daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 58 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. # lost_password_controller.rb
  2.  
  3.   def create
  4.     email = params[:email].to_s
  5.  
  6.     if email.empty? # Blank email
  7.       flash[:error] = 'Enter the email address of the account.'
  8.       render :action => :show and return
  9.     end
  10.  
  11.     if !email.valid_email? # If email address is not valid
  12.       flash[:error] = 'The email address entered is not a valid email address.'
  13.       render :action => :show and return
  14.     end
  15.  
  16.     user = User.find_last_known(email) # Returns nil if user is not found
  17.  
  18.     if user.nil?
  19.       flash[:error] = 'There is no user with that email address.'
  20.       render :action => :show and return
  21.     end
  22.  
  23.     reset_token = UserPasswordResetToken.new( :user_id => user.id, :destination_url => session[:return_to] )
  24.  
  25.     if reset_token.save
  26.       LostPasswordMailer.deliver_lost_password( user.email )
  27.       render :action => :success
  28.     else
  29.       raise reset_token.errors.full_messages.join(", ")
  30.       # Couldn't save reset token
  31.       # TODO: keolo - something awesome
  32.     end
  33.   end # create
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top