diff options
author | Mark Fletcher <mark@gitlab.com> | 2017-05-01 13:22:11 +0800 |
---|---|---|
committer | Mark Fletcher <mark@gitlab.com> | 2017-05-03 17:37:08 +0800 |
commit | d02e7226c47db88549f54d0fed0e2b33a726908d (patch) | |
tree | 1145e47e2eadab18b9c082ab00b4dfad4db25853 /app/services | |
parent | 03f13af588cf2b578a27717db492c216fcafbf9a (diff) | |
download | gitlab-ce-d02e7226c47db88549f54d0fed0e2b33a726908d.tar.gz |
Detect already enabled DeployKeys in EnableDeployKeyService
Ensures deploy keys can't be re-added, which causes a validation error
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/enable_deploy_key_service.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/services/projects/enable_deploy_key_service.rb b/app/services/projects/enable_deploy_key_service.rb index 3cf4264ce9b..121385afca3 100644 --- a/app/services/projects/enable_deploy_key_service.rb +++ b/app/services/projects/enable_deploy_key_service.rb @@ -4,7 +4,10 @@ module Projects key = accessible_keys.find_by(id: params[:key_id] || params[:id]) return unless key - project.deploy_keys << key + unless project.deploy_keys.include?(key) + project.deploy_keys << key + end + key end |