Class: Core::Abilities::Application
- Defined in:
- app/api/core/abilities.rb
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.
143 144 145 146 |
# File 'app/api/core/abilities.rb', line 143 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.
184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'app/api/core/abilities.rb', line 184 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
148 149 150 |
# File 'app/api/core/abilities.rb', line 148 def privilege @api_application.privilege.to_sym end |