Commit d12579aa43372bdaa5989eee95db9c10e89befe7
Exists in
master
and in
4 other branches
Merge branch 'api' of https://github.com/NARKOZ/gitlabhq into api
Showing
4 changed files
with
19 additions
and
10 deletions
Show diff stats
app/views/help/api.html.haml
| @@ -14,6 +14,8 @@ | @@ -14,6 +14,8 @@ | ||
| 14 | %li | 14 | %li |
| 15 | %a{href: "#users"} Users | 15 | %a{href: "#users"} Users |
| 16 | %li | 16 | %li |
| 17 | + %a{href: "#session"} Session | ||
| 18 | + %li | ||
| 17 | %a{href: "#issues"} Issues | 19 | %a{href: "#issues"} Issues |
| 18 | %li | 20 | %li |
| 19 | %a{href: "#milestones"} Milestones | 21 | %a{href: "#milestones"} Milestones |
| @@ -58,6 +60,16 @@ | @@ -58,6 +60,16 @@ | ||
| 58 | 60 | ||
| 59 | %br | 61 | %br |
| 60 | 62 | ||
| 63 | +.file_holder#session | ||
| 64 | + .file_title | ||
| 65 | + %i.icon-file | ||
| 66 | + Session | ||
| 67 | + .file_content.wiki | ||
| 68 | + = preserve do | ||
| 69 | + = markdown File.read(Rails.root.join("doc", "api", "session.md")) | ||
| 70 | + | ||
| 71 | +%br | ||
| 72 | + | ||
| 61 | .file_holder#issues | 73 | .file_holder#issues |
| 62 | .file_title | 74 | .file_title |
| 63 | %i.icon-file | 75 | %i.icon-file |
lib/api/entities.rb
| @@ -9,8 +9,8 @@ module Gitlab | @@ -9,8 +9,8 @@ module Gitlab | ||
| 9 | expose :id, :email, :name, :blocked, :created_at | 9 | expose :id, :email, :name, :blocked, :created_at |
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | - class UserLogin < Grape::Entity | ||
| 13 | - expose :id, :email, :name, :private_token, :blocked, :created_at | 12 | + class UserLogin < UserBasic |
| 13 | + expose :private_token | ||
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | class Hook < Grape::Entity | 16 | class Hook < Grape::Entity |
| @@ -56,9 +56,7 @@ module Gitlab | @@ -56,9 +56,7 @@ module Gitlab | ||
| 56 | end | 56 | end |
| 57 | 57 | ||
| 58 | class Key < Grape::Entity | 58 | class Key < Grape::Entity |
| 59 | - expose :id, | ||
| 60 | - :title, | ||
| 61 | - :key | 59 | + expose :id, :title, :key |
| 62 | end | 60 | end |
| 63 | end | 61 | end |
| 64 | end | 62 | end |
lib/api/session.rb
| @@ -8,14 +8,13 @@ module Gitlab | @@ -8,14 +8,13 @@ module Gitlab | ||
| 8 | post "/session" do | 8 | post "/session" do |
| 9 | resource = User.find_for_database_authentication(email: params[:email]) | 9 | resource = User.find_for_database_authentication(email: params[:email]) |
| 10 | 10 | ||
| 11 | - return forbidden! unless resource | 11 | + return unauthorized! unless resource |
| 12 | 12 | ||
| 13 | if resource.valid_password?(params[:password]) | 13 | if resource.valid_password?(params[:password]) |
| 14 | present resource, with: Entities::UserLogin | 14 | present resource, with: Entities::UserLogin |
| 15 | else | 15 | else |
| 16 | - forbidden! | 16 | + unauthorized! |
| 17 | end | 17 | end |
| 18 | end | 18 | end |
| 19 | end | 19 | end |
| 20 | end | 20 | end |
| 21 | - |
spec/requests/api/session_spec.rb
| @@ -19,7 +19,7 @@ describe Gitlab::API do | @@ -19,7 +19,7 @@ describe Gitlab::API do | ||
| 19 | context "when invalid password" do | 19 | context "when invalid password" do |
| 20 | it "should return authentication error" do | 20 | it "should return authentication error" do |
| 21 | post api("/session"), email: user.email, password: '123' | 21 | post api("/session"), email: user.email, password: '123' |
| 22 | - response.status.should == 403 | 22 | + response.status.should == 401 |
| 23 | 23 | ||
| 24 | json_response['email'].should be_nil | 24 | json_response['email'].should be_nil |
| 25 | json_response['private_token'].should be_nil | 25 | json_response['private_token'].should be_nil |
| @@ -29,7 +29,7 @@ describe Gitlab::API do | @@ -29,7 +29,7 @@ describe Gitlab::API do | ||
| 29 | context "when empty password" do | 29 | context "when empty password" do |
| 30 | it "should return authentication error" do | 30 | it "should return authentication error" do |
| 31 | post api("/session"), email: user.email | 31 | post api("/session"), email: user.email |
| 32 | - response.status.should == 403 | 32 | + response.status.should == 401 |
| 33 | 33 | ||
| 34 | json_response['email'].should be_nil | 34 | json_response['email'].should be_nil |
| 35 | json_response['private_token'].should be_nil | 35 | json_response['private_token'].should be_nil |