Sha256: d16f277446cf81cde17fb86f534a3adc499d3fba5ec27d9c7ebf14a7127958c0

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meroku-2.0.8 frontend/app/models/user.rb