feat: don't allow more documents than permitted
This commit is contained in:
@@ -3,6 +3,7 @@ class Api::V1::Accounts::Captain::DocumentsController < Api::V1::Accounts::BaseC
|
||||
before_action -> { check_authorization(Captain::Assistant) }
|
||||
|
||||
before_action :set_current_page, only: [:index]
|
||||
before_action :ensure_within_plan_limit, only: [:create]
|
||||
before_action :set_documents, except: [:create]
|
||||
before_action :set_document, only: [:show, :destroy]
|
||||
before_action :set_assistant, only: [:create]
|
||||
@@ -48,6 +49,10 @@ class Api::V1::Accounts::Captain::DocumentsController < Api::V1::Accounts::BaseC
|
||||
@current_page = permitted_params[:page] || 1
|
||||
end
|
||||
|
||||
def ensure_within_plan_limit
|
||||
Current.account.account.usage_limits[:captain][:documents][:current_available].positive?
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
params.permit(:assistant_id, :page, :id, :account_id)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user