I’m passing in
{"email":"invalidemail@gibberish.com"}
as the parameters.
I’m getting a 200 response with a nil body. Why do I not see a 401?
When I run the first
User.where('email = ?', params[:email]).first
query in the console, I get nil. I’ve also tried with passwords, testing invalid passwords. In the console, it fails. But I keep getting a 200 response here:
def sign_in
user = User.where('email = ?', params[:email]).first
if !user
render :json => user, status => 401
return
end
if user.valid_password?(params[:password])
render :json => user
return
end
render :json => user, status => 401
end
You should use
headinstead to return just the401code without page content :