title: Devise find by username or email
body: <p>after setup devise 
  i would like to get the user by username or email with in a api session</p>
  
  <p>I passed login to parameters but rails spits out a error</p>
  
  <pre><code>User.find_for_database_authentication(:login =&gt; params[:username][:email])
  </code></pre>
  
  <p>the overwrite of find_for_database_authentication on model is already done.</p>
  
  <pre><code>def self.find_for_database_authentication(warden_conditions)
  </code></pre>
  
  <p>Someone has any hint to spare?</p>
  
  <p><strong>Devise</strong></p>
  
  <pre><code>class Api::SessionsController &lt; Devise::SessionsController
  
    respond_to :json
  
    def create
      resource = User.find_for_database_authentication(:login =&gt; params[:username][:email])
  
  
  
      if resource.valid_password?(params[:login][:password])
        sign_in(:user, resource)
  
        render :json=&gt; {:auth_token=&gt;resource.authentication_token, :email=&gt;resource.email}, :status =&gt; :ok
        return
      end
      invalid_login_attempt
    end
  end
  </code></pre>