Skip to content
Snippets Groups Projects
Commit 49fe8fed authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge branch 'api'

parents a605943d d12579aa
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -13,6 +13,8 @@
%a{href: "#snippets"} Snippets
%li
%a{href: "#users"} Users
%li
%a{href: "#session"} Session
%li
%a{href: "#issues"} Issues
%li
Loading
Loading
@@ -58,6 +60,16 @@
 
%br
 
.file_holder#session
.file_title
%i.icon-file
Session
.file_content.wiki
= preserve do
= markdown File.read(Rails.root.join("doc", "api", "session.md"))
%br
.file_holder#issues
.file_title
%i.icon-file
Loading
Loading
Loading
Loading
@@ -9,8 +9,8 @@ module Gitlab
expose :id, :email, :name, :blocked, :created_at
end
 
class UserLogin < Grape::Entity
expose :id, :email, :name, :private_token, :blocked, :created_at
class UserLogin < UserBasic
expose :private_token
end
 
class Hook < Grape::Entity
Loading
Loading
@@ -56,9 +56,7 @@ module Gitlab
end
 
class Key < Grape::Entity
expose :id,
:title,
:key
expose :id, :title, :key
end
end
end
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