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
28e7d1a8
Commit
28e7d1a8
authored
Mar 18, 2013
by
Alex Denisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abilities added to /user and /sign_in requests
parent
6956f1f6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
4 deletions
+16
-4
lib/api/entities.rb
lib/api/entities.rb
+5
-1
lib/api/projects.rb
lib/api/projects.rb
+2
-2
lib/api/users.rb
lib/api/users.rb
+1
-1
spec/requests/api/session_spec.rb
spec/requests/api/session_spec.rb
+4
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+4
-0
No files found.
lib/api/entities.rb
View file @
28e7d1a8
...
@@ -15,6 +15,10 @@ module Gitlab
...
@@ -15,6 +15,10 @@ module Gitlab
class
UserLogin
<
UserBasic
class
UserLogin
<
UserBasic
expose
:private_token
expose
:private_token
expose
:is_admin?
,
as: :is_admin
expose
:can_create_group?
,
as: :can_create_group
expose
:can_create_project?
,
as: :can_create_project
expose
:can_create_team?
,
as: :can_create_team
end
end
class
Hook
<
Grape
::
Entity
class
Hook
<
Grape
::
Entity
...
@@ -31,7 +35,7 @@ module Gitlab
...
@@ -31,7 +35,7 @@ module Gitlab
end
end
class
ProjectMember
<
UserBasic
class
ProjectMember
<
UserBasic
expose
:project_access
,
:as
=>
:access_level
do
|
user
,
options
|
expose
:project_access
,
as:
:access_level
do
|
user
,
options
|
options
[
:project
].
users_projects
.
find_by_user_id
(
user
.
id
).
project_access
options
[
:project
].
users_projects
.
find_by_user_id
(
user
.
id
).
project_access
end
end
end
end
...
...
lib/api/projects.rb
View file @
28e7d1a8
...
@@ -191,7 +191,7 @@ module Gitlab
...
@@ -191,7 +191,7 @@ module Gitlab
unless
team_member
.
nil?
unless
team_member
.
nil?
team_member
.
destroy
team_member
.
destroy
else
else
{
:message
=>
"Access revoked"
,
:id
=>
params
[
:user_id
].
to_i
}
{
message:
"Access revoked"
,
id:
params
[
:user_id
].
to_i
}
end
end
end
end
...
@@ -322,7 +322,7 @@ module Gitlab
...
@@ -322,7 +322,7 @@ module Gitlab
protected
=
user_project
.
protected_branches
.
find_by_name
(
@branch
.
name
)
protected
=
user_project
.
protected_branches
.
find_by_name
(
@branch
.
name
)
unless
protected
unless
protected
user_project
.
protected_branches
.
create
(
:name
=>
@branch
.
name
)
user_project
.
protected_branches
.
create
(
name:
@branch
.
name
)
end
end
present
@branch
,
with:
Entities
::
RepoObject
,
project:
user_project
present
@branch
,
with:
Entities
::
RepoObject
,
project:
user_project
...
...
lib/api/users.rb
View file @
28e7d1a8
...
@@ -124,7 +124,7 @@ module Gitlab
...
@@ -124,7 +124,7 @@ module Gitlab
# Example Request:
# Example Request:
# GET /user
# GET /user
get
do
get
do
present
@current_user
,
with:
Entities
::
User
present
@current_user
,
with:
Entities
::
User
Login
end
end
# Get currently authenticated user's keys
# Get currently authenticated user's keys
...
...
spec/requests/api/session_spec.rb
View file @
28e7d1a8
...
@@ -13,6 +13,10 @@ describe Gitlab::API do
...
@@ -13,6 +13,10 @@ describe Gitlab::API do
json_response
[
'email'
].
should
==
user
.
email
json_response
[
'email'
].
should
==
user
.
email
json_response
[
'private_token'
].
should
==
user
.
private_token
json_response
[
'private_token'
].
should
==
user
.
private_token
json_response
[
'is_admin'
].
should
==
user
.
is_admin?
json_response
[
'can_create_team'
].
should
==
user
.
can_create_team?
json_response
[
'can_create_project'
].
should
==
user
.
can_create_project?
json_response
[
'can_create_group'
].
should
==
user
.
can_create_group?
end
end
end
end
...
...
spec/requests/api/users_spec.rb
View file @
28e7d1a8
...
@@ -214,6 +214,10 @@ describe Gitlab::API do
...
@@ -214,6 +214,10 @@ describe Gitlab::API do
get
api
(
"/user"
,
user
)
get
api
(
"/user"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'email'
].
should
==
user
.
email
json_response
[
'email'
].
should
==
user
.
email
json_response
[
'is_admin'
].
should
==
user
.
is_admin?
json_response
[
'can_create_team'
].
should
==
user
.
can_create_team?
json_response
[
'can_create_project'
].
should
==
user
.
can_create_project?
json_response
[
'can_create_group'
].
should
==
user
.
can_create_group?
end
end
it
"should return 401 error if user is unauthenticated"
do
it
"should return 401 error if user is unauthenticated"
do
...
...
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