Class: User

Inherits:
Object
  • Object
show all
Includes:
App47EmailSendable, App47Logger, Mongoid::Document, Mongoid::Timestamps, Searchable
Defined in:
lib/models/user.rb

Overview

A user in the system is someone who has access to the enterprise app store

Direct Known Subclasses

Cat::Customer, Cl::Customer, Gehc::Customer, SsoUser

Instance Method Summary collapse

Methods included from Searchable

included

Methods included from App47Logger

log_debug, #log_debug, log_error, #log_error, log_exception, log_message, #log_message, #log_warn, log_warn

Methods included from App47EmailSendable

included

Instance Method Details

#allowed_app_setObject

Return the unique set of application ids for this given user



32
33
34
# File 'lib/models/user.rb', line 32

def allowed_app_set
  app_permissions.collect(&:app) + .apps.distinct_all_users
end

#find_device_by(device_id) ⇒ Object

Find a user device by safely trying a number of approaches

  1. By ID

  2. By unique identifier

  3. By app47 identifier

  4. By token



43
44
45
46
47
48
49
50
51
52
# File 'lib/models/user.rb', line 43

def find_device_by(device_id)
  raise 'Invalid ID' if device_id.blank?

  devices.where(_id: device_id).first ||
    devices.where(unique_identifier: device_id).first ||
    devices.where(app47_identifier: device_id).first ||
    devices.where(token: device_id).first
rescue StandardError
  nil
end