Class: Core::Services::Applications
- Includes:
- Singleton
- Defined in:
- lib/core/services/applications.rb
Overview
Service managing applications, allowing easy access to them with or without providing client secret for example.
Instance Method Summary collapse
-
#get_by_credentials(client_id: nil, client_secret: nil, **_ignored) ⇒ Core::Models::OAuth::Application
Gets an application given its credentials (client UUID and client secret).
-
#get_by_id(client_id: nil, **_ignored) ⇒ Core::Models::OAuth::Application
Gets an application given its client UUID.
Methods inherited from Base
#bad_request_err, #forbidden_err, #require_parameters, #unknown_err
Instance Method Details
#get_by_credentials(client_id: nil, client_secret: nil, **_ignored) ⇒ Core::Models::OAuth::Application
Gets an application given its credentials (client UUID and client secret).
20 21 22 23 24 25 26 |
# File 'lib/core/services/applications.rb', line 20 def get_by_credentials(client_id: nil, client_secret: nil, **_ignored) require_parameters client_secret: client_secret application = get_by_id(client_id: client_id) raise forbidden_err(field: 'client_secret', error: 'wrong') unless application.has_secret?(client_secret) application end |
#get_by_id(client_id: nil, **_ignored) ⇒ Core::Models::OAuth::Application
Gets an application given its client UUID.
34 35 36 37 38 39 40 |
# File 'lib/core/services/applications.rb', line 34 def get_by_id(client_id: nil, **_ignored) require_parameters client_id: client_id application = Core::Models::OAuth::Application.find_by(client_id: client_id) raise unknown_err(field: 'client_id') if application.nil? Core::Decorators::Application.new(application) end |