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:
authorPatricio Cano <suprnova32@gmail.com>2016-08-31 02:43:24 +0300
committerPatricio Cano <suprnova32@gmail.com>2016-09-15 20:21:00 +0300
commitc25630ee2c2804e351a2c3ae4fd9224434e4698a (patch)
tree7d183ef29da41a3c3b53790a2fc48402d1f4f397 /lib/gitlab/auth.rb
parent48f1a61fd5c6aac395be0ce5d59aee61bbb69fe9 (diff)
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.rb19
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