Guest User

Untitled

a guest
Apr 21st, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. def login
  2. redirect_back_or_default(home_path) and return if @u
  3. @user = User.new
  4. return unless request.post?
  5.  
  6.  
  7. #plays double duty login/forgot (due to the ajax nature of the login/forgot form)
  8. if params[:email] && params[:email].size > 0
  9. u = Profile.find_by_email(params[:email]).user rescue nil
  10. flash.now[:error] = "Could not find that email address. Try again." and return if u.nil?
  11.  
  12. @pass = u.forgot_password #must be @ variable for function tests
  13. AccountMailer.deliver_forgot_password(u.profile.email, u.f, u.login, @pass)
  14. flash[:notice] = "A new password has been mailed to you."
  15. else
  16. params[:login] ||= params[:user][:login] if params[:user]
  17. params[:password] ||= params[:user][:password] if params[:user]
  18. self.user = User.authenticate(params[:login], params[:password])
  19. if @u
  20. remember_me if params[:remember_me] == "1"
  21. flash[:notice] = "Hello #{@u.f}"
  22. redirect_back_or_default home_path
  23. else
  24. flash.now[:error] = "Uh-oh, login didn't work. Do you have caps locks on? Try it again."
  25. end
  26. end
  27. end
Add Comment
Please, Sign In to add comment