Sha256: fbee2cfd471894222972f7a1fcdaa43d84735fcb75166d79b5f3823f819274cd

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

module DqAdmin
  class User < ApplicationRecord

    DEFAULT_USER_EMAIL = 'admin@dq.com'

    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable,
           :recoverable, 
           :rememberable, 
           :trackable, 
           :validatable


    def self.populate        
      if User.count == 0
        password = SecureRandom.hex
        User.create(email: User::DEFAULT_USER_EMAIL, username: 'root', password: password, password_confirmation: password)
        Rails.logger.info "[DQ] root user email: #{DEFAULT_USER_EMAIL} password: #{password}"
      end
    end

    def self.generate_test_users
      100.times do |i|
        name = rand(36**10).to_s(36)
        User.create(email: "#{name}@sap.com", username: name, password: 'password', password_confirmation: 'password')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dq_admin-0.1.0 app/models/dq_admin/user.rb