summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-03-13 11:04:33 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-03-13 11:04:33 +0000
commitd1df36e3864967f65f662c1367d3bdfe993beadd (patch)
tree09cdc737f73baa94ae9b1e47100e9f8aa96ec4a5 /lib/api
parentf49868adf1a2ea24815d432640cd0d996e0d87a0 (diff)
parent90e11fb272cd30e7e61be16d862830f2b69a624a (diff)
downloadgitlab-ce-d1df36e3864967f65f662c1367d3bdfe993beadd.tar.gz
Merge branch 'refactor/global-permissions-for-internal-users' into 'master'
Refactor/global permissions for internal users See merge request !9598
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/helpers.rb6
-rw-r--r--lib/api/users.rb2
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index a9b364da9e1..bd22b82476b 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -97,7 +97,7 @@ module API
end
def authenticate!
- unauthorized! unless current_user
+ unauthorized! unless current_user && can?(current_user, :access_api)
end
def authenticate_non_get!
@@ -116,7 +116,7 @@ module API
forbidden! unless current_user.is_admin?
end
- def authorize!(action, subject = nil)
+ def authorize!(action, subject = :global)
forbidden! unless can?(current_user, action, subject)
end
@@ -134,7 +134,7 @@ module API
end
end
- def can?(object, action, subject)
+ def can?(object, action, subject = :global)
Ability.allowed?(object, action, subject)
end
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 549003f576a..2d4d5a25221 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -45,7 +45,7 @@ module API
use :pagination
end
get do
- unless can?(current_user, :read_users_list, nil)
+ unless can?(current_user, :read_users_list)
render_api_error!("Not authorized.", 403)
end