Class: Core::Abilities::Application
- Defined in:
- app/api/core/abilities.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
-
#authenticate!(user_ability) ⇒ Object
The decision as to whether the application requires the user to be authenticated is made by the application.
-
#initialize(request) ⇒ Application
constructor
A new instance of Application.
- #privilege ⇒ Object
Methods included from Base::ClassMethods
Constructor Details
#initialize(request) ⇒ Application
Returns a new instance of Application.
139 140 141 142 |
# File 'app/api/core/abilities.rb', line 139 def initialize(request) @api_application = ApiApplication.find_by(key: request.) super end |
Instance Method Details
#authenticate!(user_ability) ⇒ Object
The decision as to whether the application requires the user to be authenticated is made by the application. If it does, however, then the user abilities may need to be changed so we need to modify that too.
179 180 181 182 183 184 185 186 187 188 189 |
# File 'app/api/core/abilities.rb', line 179 def authenticate!(user_ability) = @request.authentication_code if .blank? && cannot?(:authenticate, :nil) Core::Service::Authentication::UnauthenticatedError. elsif .present? user = ::User.find_by(api_key: ) or Core::Service::Authentication::UnauthenticatedError.unauthenticated! @request.service.instance_variable_set(:@user, user) end user_ability.authenticated! end |
#privilege ⇒ Object
144 145 146 |
# File 'app/api/core/abilities.rb', line 144 def privilege @api_application.privilege.to_sym end |