frontend/app/models/publickey.rb in meroku-2.0.4 vs frontend/app/models/publickey.rb in meroku-2.0.5

- old
+ new

@@ -1,14 +1,15 @@ class Publickey < ApplicationRecord belongs_to :user + after_commit :do_refresh, on: [:create] # Updates /home/git/.ssh/authorized_keys # called when something added/?/etc to publickeys table - def self.refresh + def do_refresh Rails.logger.debug "DB8 publickey.rb:def self.refresh called" - Rails.logger.debug "wipwip" - end - - def after_save - Publickey.refresh + if Publickey.all.size > 0 + File.write('/tmp/authorized_keys', Publickey.pluck(:data).join("\n") ) + system("sudo -u git cp /tmp/authorized_keys /home/git/.ssh/authorized_keys") + File.delete('/tmp/authorized_keys') + end end end