Module: HasHelpers::Middleware::ApplicationAccess
- Included in:
- HasHelpers::Mutations::Base, Resolvers::Base
- Defined in:
- app/graphql/has_helpers/middleware/application_access.rb
Instance Method Summary collapse
-
#authorized?(**_args) ⇒ Boolean
Runs before any GraphQL resource to validate app access and continue if authorized.
Instance Method Details
#authorized?(**_args) ⇒ Boolean
Runs before any GraphQL resource to validate app access and continue if authorized
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/graphql/has_helpers/middleware/application_access.rb', line 7 def (**_args) # NOTE: ideally application_access_control should disable access control, but it's kept like this temporarily for backward compatibility return true if ::Rails.application.config.x.application_access_control.blank? return true if self.class.const_defined?(:SKIP_APP_ACCESS_CHECK) && self.class::SKIP_APP_ACCESS_CHECK return true unless context[:current_user] && context[:current_application] allowed = context[:current_user]. user_organizations. where(organization_id: context[:current_organization]&.id). any? { |uo| uo.applications_array.include?(context[:current_application].name) } raise GraphQL::ExecutionError, "Unauthorized to access this app" unless allowed true end |