Skip to content
Snippets Groups Projects
Commit b08d33f6 authored by Nihad Abbasov's avatar Nihad Abbasov
Browse files

API: return 401 for invalid session

parent 3dd940d4
No related branches found
No related tags found
1 merge request!1514Session API polishing
Loading
Loading
@@ -8,14 +8,13 @@ module Gitlab
post "/session" do
resource = User.find_for_database_authentication(email: params[:email])
 
return forbidden! unless resource
return unauthorized! unless resource
 
if resource.valid_password?(params[:password])
present resource, with: Entities::UserLogin
else
forbidden!
unauthorized!
end
end
end
end
Loading
Loading
@@ -19,7 +19,7 @@ describe Gitlab::API do
context "when invalid password" do
it "should return authentication error" do
post api("/session"), email: user.email, password: '123'
response.status.should == 403
response.status.should == 401
 
json_response['email'].should be_nil
json_response['private_token'].should be_nil
Loading
Loading
@@ -29,7 +29,7 @@ describe Gitlab::API do
context "when empty password" do
it "should return authentication error" do
post api("/session"), email: user.email
response.status.should == 403
response.status.should == 401
 
json_response['email'].should be_nil
json_response['private_token'].should be_nil
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment