title: Rails has_secure_password authentication errors
body: <p>This is my user:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_secure_password
  end
  </code></pre>
  
  <p>This is how someone can authenticate via API:</p>
  
  <pre><code>module Api
    class SessionsController &lt; ApiController
      def create
        user = User.find_by_email(params[:user][:email])
        if user &amp;&amp; user.authenticate(params[:user][:password])
          # some login logic
        else
          render json: {messages: user.errors.full_messages}, status: :unauthorized
        end
      end
    end
  end
  </code></pre>
  
  <p>If I pass an incorrect password, I get 401 Unauthorized as expected. However, <code>user.errors</code> is blank. How can I access <code>has_secure_password</code> authentication errors?</p>