Class: BBMB::Html::Util::KnownUser

Inherits:
SBSM::User
  • Object
show all
Defined in:
lib/bbmb/html/util/known_user.rb

Constant Summary collapse

PREFERENCE_KEYS =
[ :home, :pagestep ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ KnownUser

Returns a new instance of KnownUser.



25
26
27
# File 'lib/bbmb/html/util/known_user.rb', line 25

def initialize(session)
  @auth_session = session
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject



47
48
49
50
51
# File 'lib/bbmb/html/util/known_user.rb', line 47

def remote_call(method, *args, &block)
  @auth_session.send(method, *args, &block)
rescue RangeError, DRb::DRbError => e
  BBMB.logger.error('auth') { e }
end

Instance Attribute Details

#auth_sessionObject (readonly)

Admin users need permissions for: login BBMB.config.auth_domain + ".Admin" edit yus.entities set_password grant login

Customers need permissions for: login BBMB.config.auth_domain + ".Customer"



18
19
20
# File 'lib/bbmb/html/util/known_user.rb', line 18

def auth_session
  @auth_session
end

Instance Method Details

#allowed?(action, key = nil) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
# File 'lib/bbmb/html/util/known_user.rb', line 28

def allowed?(action, key=nil)
  allowed = remote_call(:allowed?, action, key)
  BBMB.logger.debug('User') {
    sprintf('%s: allowed?(%s, %s) -> %s', name, action, key, allowed)
  }
  allowed
end

#entity_valid?(email) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/bbmb/html/util/known_user.rb', line 35

def entity_valid?(email)
  !!(allowed?('edit', 'yus.entities') \
    && (entity = remote_call(:find_entity, email)) && entity.valid?)
end


39
40
41
# File 'lib/bbmb/html/util/known_user.rb', line 39

def navigation
  [ :logout ]
end

#remote_call(method, *args, &block) ⇒ Object Also known as: method_missing



42
43
44
45
46
# File 'lib/bbmb/html/util/known_user.rb', line 42

def remote_call(method, *args, &block)
  @auth_session.send(method, *args, &block)
rescue RangeError, DRb::DRbError => e
  BBMB.logger.error('auth') { e }
end