diff options
author | Lin Jen-Shin (godfat) <godfat@godfat.org> | 2017-11-13 18:27:30 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-11-13 18:27:30 +0300 |
commit | 258bf3e187538bd326491e5d1b25a0511fbd96a1 (patch) | |
tree | 366d7dfbd59ce1e64ec46eb98ea36c83317d02df /lib/api | |
parent | 4a1e8188f96744103e51263c9bdc071c8e088690 (diff) |
Add Gitlab::Utils::StrongMemoize
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api_guard.rb | 8 |
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: []) |