Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
d12579aa
Commit
d12579aa
authored
Sep 20, 2012
by
randx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'api' of
https://github.com/NARKOZ/gitlabhq
into api
parents
a605943d
81aeac46
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
app/views/help/api.html.haml
app/views/help/api.html.haml
+12
-0
lib/api/entities.rb
lib/api/entities.rb
+3
-5
lib/api/session.rb
lib/api/session.rb
+2
-3
spec/requests/api/session_spec.rb
spec/requests/api/session_spec.rb
+2
-2
No files found.
app/views/help/api.html.haml
View file @
d12579aa
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
%a
{
href:
"#snippets"
}
Snippets
%a
{
href:
"#snippets"
}
Snippets
%li
%li
%a
{
href:
"#users"
}
Users
%a
{
href:
"#users"
}
Users
%li
%a
{
href:
"#session"
}
Session
%li
%li
%a
{
href:
"#issues"
}
Issues
%a
{
href:
"#issues"
}
Issues
%li
%li
...
@@ -58,6 +60,16 @@
...
@@ -58,6 +60,16 @@
%br
%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_holder
#issues
.file_title
.file_title
%i
.icon-file
%i
.icon-file
...
...
lib/api/entities.rb
View file @
d12579aa
...
@@ -9,8 +9,8 @@ module Gitlab
...
@@ -9,8 +9,8 @@ module Gitlab
expose
:id
,
:email
,
:name
,
:blocked
,
:created_at
expose
:id
,
:email
,
:name
,
:blocked
,
:created_at
end
end
class
UserLogin
<
Grape
::
Entity
class
UserLogin
<
UserBasic
expose
:
id
,
:email
,
:name
,
:private_token
,
:blocked
,
:created_at
expose
:
private_token
end
end
class
Hook
<
Grape
::
Entity
class
Hook
<
Grape
::
Entity
...
@@ -56,9 +56,7 @@ module Gitlab
...
@@ -56,9 +56,7 @@ module Gitlab
end
end
class
Key
<
Grape
::
Entity
class
Key
<
Grape
::
Entity
expose
:id
,
expose
:id
,
:title
,
:key
:title
,
:key
end
end
end
end
end
end
lib/api/session.rb
View file @
d12579aa
...
@@ -8,14 +8,13 @@ module Gitlab
...
@@ -8,14 +8,13 @@ module Gitlab
post
"/session"
do
post
"/session"
do
resource
=
User
.
find_for_database_authentication
(
email:
params
[
:email
])
resource
=
User
.
find_for_database_authentication
(
email:
params
[
:email
])
return
forbidden
!
unless
resource
return
unauthorized
!
unless
resource
if
resource
.
valid_password?
(
params
[
:password
])
if
resource
.
valid_password?
(
params
[
:password
])
present
resource
,
with:
Entities
::
UserLogin
present
resource
,
with:
Entities
::
UserLogin
else
else
forbidden
!
unauthorized
!
end
end
end
end
end
end
end
end
spec/requests/api/session_spec.rb
View file @
d12579aa
...
@@ -19,7 +19,7 @@ describe Gitlab::API do
...
@@ -19,7 +19,7 @@ describe Gitlab::API do
context
"when invalid password"
do
context
"when invalid password"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
post
api
(
"/session"
),
email:
user
.
email
,
password:
'123'
post
api
(
"/session"
),
email:
user
.
email
,
password:
'123'
response
.
status
.
should
==
40
3
response
.
status
.
should
==
40
1
json_response
[
'email'
].
should
be_nil
json_response
[
'email'
].
should
be_nil
json_response
[
'private_token'
].
should
be_nil
json_response
[
'private_token'
].
should
be_nil
...
@@ -29,7 +29,7 @@ describe Gitlab::API do
...
@@ -29,7 +29,7 @@ describe Gitlab::API do
context
"when empty password"
do
context
"when empty password"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
post
api
(
"/session"
),
email:
user
.
email
post
api
(
"/session"
),
email:
user
.
email
response
.
status
.
should
==
40
3
response
.
status
.
should
==
40
1
json_response
[
'email'
].
should
be_nil
json_response
[
'email'
].
should
be_nil
json_response
[
'private_token'
].
should
be_nil
json_response
[
'private_token'
].
should
be_nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment