Sha256: b898b1fd6cd08a0302d744e76ccb9a13b6ffba9a4b2c63a0f6609a6177efcc43

Contents?: true

Size: 937 Bytes

Versions: 5

Compression:

Stored size: 937 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
    rescue => e
    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

5 entries across 5 versions & 1 rubygems

Version Path
dq_admin-0.4.3 app/models/dq_admin/user.rb
dq_admin-0.4.2 app/models/dq_admin/user.rb
dq_admin-0.4.0 app/models/dq_admin/user.rb
dq_admin-0.3.0 app/models/dq_admin/user.rb
dq_admin-0.2.0 app/models/dq_admin/user.rb