add remove keys from gitlab-shell by id
This commit is contained in:
parent
081c272b85
commit
39e37677f2
3 changed files with 10 additions and 10 deletions
|
@ -81,7 +81,7 @@ class Key < ActiveRecord::Base
|
|||
Key.where(identifier: identifier).count == 0
|
||||
end
|
||||
|
||||
def owner_name
|
||||
user.username
|
||||
def shell_id
|
||||
"key-#{self.id}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class KeyObserver < ActiveRecord::Observer
|
|||
def after_save(key)
|
||||
GitoliteWorker.perform_async(
|
||||
:add_key,
|
||||
key.owner_name,
|
||||
key.shell_id,
|
||||
key.key
|
||||
)
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ class KeyObserver < ActiveRecord::Observer
|
|||
def after_destroy(key)
|
||||
GitoliteWorker.perform_async(
|
||||
:remove_key,
|
||||
key.owner_name,
|
||||
key.shell_id,
|
||||
key.key,
|
||||
)
|
||||
end
|
||||
|
|
|
@ -27,19 +27,19 @@ module Gitlab
|
|||
# Add new key to gitlab-shell
|
||||
#
|
||||
# Ex.
|
||||
# add_key("randx", "sha-rsa ...")
|
||||
# add_key("key-42", "sha-rsa ...")
|
||||
#
|
||||
def add_key(username, key_content)
|
||||
system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{username} \"#{key_content}\"")
|
||||
def add_key(key_id, key_content)
|
||||
system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"")
|
||||
end
|
||||
|
||||
# Remove ssh key from gitlab shell
|
||||
#
|
||||
# Ex.
|
||||
# remove_key("sha-rsa")
|
||||
# remove_key("key-342", "sha-rsa ...")
|
||||
#
|
||||
def remove_key(username, key_content)
|
||||
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{username} \"#{key_content}\"")
|
||||
def remove_key(key_id, key_content)
|
||||
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue