Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def login
- redirect_back_or_default(home_path) and return if @u
- @user = User.new
- return unless request.post?
- #plays double duty login/forgot (due to the ajax nature of the login/forgot form)
- if params[:email] && params[:email].size > 0
- u = Profile.find_by_email(params[:email]).user rescue nil
- flash.now[:error] = "Could not find that email address. Try again." and return if u.nil?
- @pass = u.forgot_password #must be @ variable for function tests
- AccountMailer.deliver_forgot_password(u.profile.email, u.f, u.login, @pass)
- flash[:notice] = "A new password has been mailed to you."
- else
- params[:login] ||= params[:user][:login] if params[:user]
- params[:password] ||= params[:user][:password] if params[:user]
- self.user = User.authenticate(params[:login], params[:password])
- if @u
- remember_me if params[:remember_me] == "1"
- flash[:notice] = "Hello #{@u.f}"
- redirect_back_or_default home_path
- else
- flash.now[:error] = "Uh-oh, login didn't work. Do you have caps locks on? Try it again."
- end
- end
- end
Add Comment
Please, Sign In to add comment