concord-consortium/rigse

View on GitHub
rails/lib/custom_failure.rb

Summary

Maintainability
A
35 mins
Test Coverage
class CustomFailure < Devise::FailureApp

  # Disable redirects (by redirecting to the current url) because of session timeouts.
  # Let the normal authentication rules force a redirect.
  def redirect
    store_location!
    message = warden.message || warden_options[:message]
    if message == :timeout
      redirect_to attempted_path
    else
      super
    end
  end

  def redirect_url
    request.referrer
  end

  # You need to override respond to eliminate recall
  def respond
    if params[:user]
      unless User.verified_imported_user?(params[:user][:login])
        session[:login] = params[:user][:login]
        redirect_to import_confirm_user_imported_login_path and return
      end
    end
    if http_auth?
      http_auth
    else
      redirect
    end
  end
end