Module: Users::Models::User

Defined in:
lib/users/models/user.rb,
lib/users/models/user/scoped.rb

Defined Under Namespace

Modules: Scoped

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/users/models/user.rb', line 5

def self.included(base)
  base.class_eval do
    attr_protected :access
    after_initialize :generate_api_key
    
    def generate_api_key
      begin
        self.api_key = ActiveSupport::SecureRandom.hex(18) unless api_key.present?
      rescue
        logger.error "attempt to create api key failed - please migrate radiant-users-extension"
      end
    end
  end
end