class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :publickeys after_commit :make_user, on: [:create] before_save do self.token = SecureRandom.hex if !self.token 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]) end end