Sha256: 70f305d37a0de777042691f93eb63da5d700dd3fbc6660e1094a942b828aa5c7

Contents?: true

Size: 844 Bytes

Versions: 12

Compression:

Stored size: 844 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.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"
    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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
meroku-2.0.22 frontend/app/models/user.rb
meroku-2.0.21 frontend/app/models/user.rb
meroku-2.0.20 frontend/app/models/user.rb
meroku-2.0.19 frontend/app/models/user.rb
meroku-2.0.18 frontend/app/models/user.rb
meroku-2.0.17 frontend/app/models/user.rb
meroku-2.0.16 frontend/app/models/user.rb
meroku-2.0.14 frontend/app/models/user.rb
meroku-2.0.13 frontend/app/models/user.rb
meroku-2.0.11 frontend/app/models/user.rb
meroku-2.0.10 frontend/app/models/user.rb
meroku-2.0.9 frontend/app/models/user.rb