Class: OktaRedis::App
- Inherits:
-
Model
- Object
- Common::RedisStore
- Model
- OktaRedis::App
- Defined in:
- app/models/okta_redis/app.rb
Constant Summary collapse
- CLASS_NAME =
'AppService'
- REDIS_CONFIG_KEY =
:okta_response_app
Constants inherited from Common::RedisStore
Common::RedisStore::REQ_CLASS_INSTANCE_VARS
Instance Attribute Summary collapse
-
#grants ⇒ Object
Returns the value of attribute grants.
Attributes inherited from Model
Instance Method Summary collapse
-
#delete_grants ⇒ Object
rubocop:enable Rails/FindEach.
-
#fetch_grants ⇒ Object
rubocop:disable Rails/FindEach.
-
#initialize(attributes = {}, persisted = false) ⇒ App
constructor
A new instance of App.
- #logo ⇒ Object
- #privacy_url ⇒ Object
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Methods included from Common::CacheAside
#cache, #cached?, #do_cached_with
Methods inherited from Common::RedisStore
create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!
Constructor Details
#initialize(attributes = {}, persisted = false) ⇒ App
Returns a new instance of App.
9 10 11 12 |
# File 'app/models/okta_redis/app.rb', line 9 def initialize(attributes = {}, persisted = false) super(attributes, persisted) @grants = [] end |
Instance Attribute Details
#grants ⇒ Object
Returns the value of attribute grants.
7 8 9 |
# File 'app/models/okta_redis/app.rb', line 7 def grants @grants end |
Instance Method Details
#delete_grants ⇒ Object
rubocop:enable Rails/FindEach
50 51 52 53 54 55 56 57 |
# File 'app/models/okta_redis/app.rb', line 50 def delete_grants raise 'Requires user set!' unless @user fetch_grants if @grants.length.zero? @user.okta_grants.delete_grants( @grants.map { |grant| grant['id'] } ) end |
#fetch_grants ⇒ Object
rubocop:disable Rails/FindEach
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/okta_redis/app.rb', line 37 def fetch_grants raise 'Requires user set!' unless @user @user.okta_grants.all.each do |grant| links = grant['_links'] app_id = links['app']['href'].split('/').last @grants << grant if app_id == @id end @grants end |
#logo ⇒ Object
22 23 24 |
# File 'app/models/okta_redis/app.rb', line 22 def logo okta_response.body['_links']['logo'].last['href'] end |
#privacy_url ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/models/okta_redis/app.rb', line 26 def privacy_url app_name = okta_response.body['label'] app_data = DirectoryApplication.find_by(name: app_name) if app_data app_data.privacy_url else '' end end |