frontend/app/models/user.rb in meroku-2.0.8 vs frontend/app/models/user.rb in meroku-2.0.9

- old
+ new

@@ -7,15 +7,16 @@ has_many :publickeys after_commit :make_user, on: [:create] before_save do - self.token = SecureRandom.hex if !self.token + self.apiusername = "u#{SecureRandom.hex[0..5]}" if !self.apiusername + self.apisecret = "s#{SecureRandom.hex[0..5]}" if !self.apisecret end def make_user Rails.logger.debug "DB8 user.rb:.make_user() called" - system(%Q[sudo adduser --disabled-password --gecos "" #{token}]) - system(%Q[sudo -u #{token} mkdir /home/#{token}/.ssh/]) - system(%Q[sudo -u #{token} touch /home/#{token}/.ssh/authorized_keys]) + Cmd.run(%Q[sudo adduser --disabled-password --gecos "" #{self.apiusername}]) + Cmd.run(%Q[sudo -u #{self.apiusername} mkdir /home/#{self.apiusername}/.ssh/]) + Cmd.run(%Q[sudo -u #{self.apiusername} touch /home/#{self.apiusername}/.ssh/authorized_keys]) end end