Commit 39e37677 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

add remove keys from gitlab-shell by id

parent 081c272b
...@@ -81,7 +81,7 @@ class Key < ActiveRecord::Base ...@@ -81,7 +81,7 @@ class Key < ActiveRecord::Base
Key.where(identifier: identifier).count == 0 Key.where(identifier: identifier).count == 0
end end
def owner_name def shell_id
user.username "key-#{self.id}"
end end
end end
...@@ -4,7 +4,7 @@ class KeyObserver < ActiveRecord::Observer ...@@ -4,7 +4,7 @@ class KeyObserver < ActiveRecord::Observer
def after_save(key) def after_save(key)
GitoliteWorker.perform_async( GitoliteWorker.perform_async(
:add_key, :add_key,
key.owner_name, key.shell_id,
key.key key.key
) )
end end
...@@ -12,7 +12,7 @@ class KeyObserver < ActiveRecord::Observer ...@@ -12,7 +12,7 @@ class KeyObserver < ActiveRecord::Observer
def after_destroy(key) def after_destroy(key)
GitoliteWorker.perform_async( GitoliteWorker.perform_async(
:remove_key, :remove_key,
key.owner_name, key.shell_id,
key.key, key.key,
) )
end end
......
...@@ -27,19 +27,19 @@ module Gitlab ...@@ -27,19 +27,19 @@ module Gitlab
# Add new key to gitlab-shell # Add new key to gitlab-shell
# #
# Ex. # Ex.
# add_key("randx", "sha-rsa ...") # add_key("key-42", "sha-rsa ...")
# #
def add_key(username, key_content) def add_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{username} \"#{key_content}\"") system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"")
end end
# Remove ssh key from gitlab shell # Remove ssh key from gitlab shell
# #
# Ex. # Ex.
# remove_key("sha-rsa") # remove_key("key-342", "sha-rsa ...")
# #
def remove_key(username, key_content) def remove_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{username} \"#{key_content}\"") system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment