Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2017-06-20 10:40:24 +0300
committerTimothy Andrew <mail@timothyandrew.net>2017-06-28 10:17:13 +0300
commit6f1922500bc9e2c6d53c46dfcbd420687dfe6e6b (patch)
treeb9de79a82757d00156ddf2f86453ae5b2ee7944d /lib/api/users.rb
parent08ad0af49c017d740b43588c0809b3811d25a448 (diff)
Initial attempt at refactoring API scope declarations.
- Declaring an endpoint's scopes in a `before` block has proved to be unreliable. For example, if we're accessing the `API::Users` endpoint - code in a `before` block in `API::API` wouldn't be able to see the scopes set in `API::Users` since the `API::API` `before` block runs first. - This commit moves these declarations to the class level, since they don't need to change once set.
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r--lib/api/users.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index f9555842daf..2cac8c089f2 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -1,9 +1,11 @@
module API
class Users < Grape::API
include PaginationParams
+ include APIGuard
+
+ allow_access_with_scope :read_user, if: -> (request) { request.get? }
before do
- allow_access_with_scope :read_user if request.get?
authenticate!
end