Class: G5Authenticatable::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- G5Authenticatable::User
- Defined in:
- app/models/g5_authenticatable/user.rb
Overview
Cache of local user data, populated based on G5 Auth
Constant Summary collapse
- GLOBAL_ROLE =
'GLOBAL'
Instance Method Summary collapse
- #attributes_from_auth(auth_data) ⇒ Object
- #clients ⇒ Object
- #locations ⇒ Object
- #selectable_clients ⇒ Object
- #update_roles_from_auth(auth_data) ⇒ Object
Instance Method Details
#attributes_from_auth(auth_data) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/models/g5_authenticatable/user.rb', line 15 def attributes_from_auth(auth_data) super(auth_data).merge( first_name: auth_data.info.first_name, last_name: auth_data.info.last_name, phone_number: auth_data.info.phone, title: auth_data.extra.title, organization_name: auth_data.extra.organization_name ) end |
#clients ⇒ Object
37 38 39 40 |
# File 'app/models/g5_authenticatable/user.rb', line 37 def clients G5Updatable::ClientPolicy::Scope.new(self, G5Updatable::Client) .resolve end |
#locations ⇒ Object
42 43 44 45 |
# File 'app/models/g5_authenticatable/user.rb', line 42 def locations G5Updatable::LocationPolicy::Scope.new(self, G5Updatable::Location) .resolve end |
#selectable_clients ⇒ Object
32 33 34 35 |
# File 'app/models/g5_authenticatable/user.rb', line 32 def selectable_clients G5Updatable::SelectableClientPolicy::Scope.new(self, G5Updatable::Client) .resolve end |
#update_roles_from_auth(auth_data) ⇒ Object
25 26 27 28 29 30 |
# File 'app/models/g5_authenticatable/user.rb', line 25 def update_roles_from_auth(auth_data) roles.clear auth_data.extra.roles.each do |role| role.type == GLOBAL_ROLE ? add_role(role.name) : add_scoped_role(role) end end |