mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #9098 from mkllnk/toggle-api
Feature-toggle API also per API key
This commit is contained in:
@@ -14,6 +14,7 @@ module Api
|
||||
attr_accessor :current_api_user
|
||||
|
||||
before_action :authenticate_user
|
||||
before_action :restrict_feature
|
||||
|
||||
rescue_from StandardError, with: :error_during_processing
|
||||
rescue_from CanCan::AccessDenied, with: :unauthorized
|
||||
@@ -38,6 +39,10 @@ module Api
|
||||
invalid_api_key
|
||||
end
|
||||
|
||||
def restrict_feature
|
||||
not_found unless Flipper.enabled?(:api_v1, @current_api_user)
|
||||
end
|
||||
|
||||
def current_ability
|
||||
Spree::Ability.new(current_api_user)
|
||||
end
|
||||
|
||||
@@ -87,7 +87,7 @@ Openfoodnetwork::Application.routes.draw do
|
||||
constraints: lambda { |_| Flipper.enabled?(:api_reports) }
|
||||
end
|
||||
|
||||
namespace :v1, constraints: ->(request) { Flipper.enabled?(:api_v1, request.env["warden"].user) } do
|
||||
namespace :v1 do
|
||||
resources :customers
|
||||
|
||||
resources :enterprises do
|
||||
|
||||
Reference in New Issue
Block a user