fix: delete user record if belongs to no account (#6664)

This commit is contained in:
Tejaswini Chile
2023-03-15 21:49:49 +05:30
committed by GitHub
parent 6848433a4c
commit cf487c76a0
2 changed files with 29 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ class Api::V1::Accounts::AgentsController < Api::V1::Accounts::BaseController
def destroy
@agent.current_account_user.destroy!
delete_user_record(@agent)
head :ok
end
@@ -74,4 +75,8 @@ class Api::V1::Accounts::AgentsController < Api::V1::Accounts::BaseController
def validate_limit
render_payment_required('Account limit exceeded. Please purchase more licenses') if agents.count >= Current.account.usage_limits[:agents]
end
def delete_user_record(agent)
DeleteObjectJob.perform_later(agent) if agent.reload.account_users.blank?
end
end