diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-08-30 18:43:24 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-09-15 12:21:00 -0500 |
commit | c25630ee2c2804e351a2c3ae4fd9224434e4698a (patch) | |
tree | 7d183ef29da41a3c3b53790a2fc48402d1f4f397 /lib/gitlab/auth.rb | |
parent | 48f1a61fd5c6aac395be0ce5d59aee61bbb69fe9 (diff) | |
download | gitlab-ce-c25630ee2c2804e351a2c3ae4fd9224434e4698a.tar.gz |
Refactored handling of the `LfsToken` and added functionality to it to simplify external code.
Diffstat (limited to 'lib/gitlab/auth.rb')
-rw-r--r-- | lib/gitlab/auth.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index 1b0398d18ee..821c0ef87e9 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -117,15 +117,16 @@ module Gitlab end def lfs_token_check(login, password) - if login.include?('lfs-deploy-key') - key = DeployKey.find(login.gsub('lfs-deploy-key-', '')) - token = Gitlab::LfsToken.new(key).value - Result.new(key, :lfs_deploy_token) if key && token == password - else - user = User.by_login(login) - token = Gitlab::LfsToken.new(user).value - Result.new(user, :lfs_token) if user && token == password - end + actor = + if login.include?('lfs-deploy-key') + DeployKey.find(login.gsub('lfs-deploy-key-', '')) + else + User.by_login(login) + end + + token_handler = Gitlab::LfsToken.new(actor) + + Result.new(actor, token_handler.type) if actor && token_handler.value == password end end end |