BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e3dcd83d
Commit
e3dcd83d
authored
Nov 10, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'grapify-session-api' into 'master'
Grapify the session API ## What are the relevant issue numbers? Related to #22928 See merge request !7381
parents
a29544f5
603ebe55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
+18
-17
session.rb
lib/api/session.rb
+9
-10
session_spec.rb
spec/requests/api/session_spec.rb
+9
-7
No files found.
lib/api/session.rb
View file @
e3dcd83d
module
API
module
API
# Users API
class
Session
<
Grape
::
API
class
Session
<
Grape
::
API
# Login to get token
desc
'Login to get token'
do
#
success
Entities
::
UserLogin
# Parameters:
end
# login (*required) - user login
params
do
# email (*required) - user email
optional
:login
,
type:
String
,
desc:
'The username'
# password (required) - user password
optional
:email
,
type:
String
,
desc:
'The email of the user'
#
requires
:password
,
type:
String
,
desc:
'The password of the user'
# Example Request:
at_least_one_of
:login
,
:email
# POST /session
end
post
"/session"
do
post
"/session"
do
user
=
Gitlab
::
Auth
.
find_with_user_password
(
params
[
:email
]
||
params
[
:login
],
params
[
:password
])
user
=
Gitlab
::
Auth
.
find_with_user_password
(
params
[
:email
]
||
params
[
:login
],
params
[
:password
])
...
...
spec/requests/api/session_spec.rb
View file @
e3dcd83d
...
@@ -67,22 +67,24 @@ describe API::API, api: true do
...
@@ -67,22 +67,24 @@ describe API::API, api: true do
end
end
context
"when empty password"
do
context
"when empty password"
do
it
"returns authentication error"
do
it
"returns authentication error
with email
"
do
post
api
(
"/session"
),
email:
user
.
email
post
api
(
"/session"
),
email:
user
.
email
expect
(
response
).
to
have_http_status
(
401
)
expect
(
json_response
[
'email'
]).
to
be_nil
expect
(
response
).
to
have_http_status
(
400
)
expect
(
json_response
[
'private_token'
]).
to
be_nil
end
it
"returns authentication error with username"
do
post
api
(
"/session"
),
email:
user
.
username
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
context
"when empty name"
do
context
"when empty name"
do
it
"returns authentication error"
do
it
"returns authentication error"
do
post
api
(
"/session"
),
password:
user
.
password
post
api
(
"/session"
),
password:
user
.
password
expect
(
response
).
to
have_http_status
(
401
)
expect
(
json_response
[
'email'
]).
to
be_nil
expect
(
response
).
to
have_http_status
(
400
)
expect
(
json_response
[
'private_token'
]).
to
be_nil
end
end
end
end
end
end
...
...
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