summaryrefslogtreecommitdiff
path: root/lib/api/api_guard.rb
diff options
context:
space:
mode:
authorLin Jen-Shin (godfat) <godfat@godfat.org>2017-11-13 15:27:30 +0000
committerRémy Coutable <remy@rymai.me>2017-11-13 15:27:30 +0000
commit258bf3e187538bd326491e5d1b25a0511fbd96a1 (patch)
tree366d7dfbd59ce1e64ec46eb98ea36c83317d02df /lib/api/api_guard.rb
parent4a1e8188f96744103e51263c9bdc071c8e088690 (diff)
downloadgitlab-ce-258bf3e187538bd326491e5d1b25a0511fbd96a1.tar.gz
Add Gitlab::Utils::StrongMemoize
Diffstat (limited to 'lib/api/api_guard.rb')
-rw-r--r--lib/api/api_guard.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb
index b9c7d443f6c..c1c0d344917 100644
--- a/lib/api/api_guard.rb
+++ b/lib/api/api_guard.rb
@@ -42,6 +42,8 @@ module API
# Helper Methods for Grape Endpoint
module HelperMethods
+ include Gitlab::Utils::StrongMemoize
+
def find_current_user!
user = find_user_from_access_token || find_user_from_warden
return unless user
@@ -52,9 +54,9 @@ module API
end
def access_token
- return @access_token if defined?(@access_token)
-
- @access_token = find_oauth_access_token || find_personal_access_token
+ strong_memoize(:access_token) do
+ find_oauth_access_token || find_personal_access_token
+ end
end
def validate_access_token!(scopes: [])