2021-01-14 15:05:22 +00:00
|
|
|
class Platform::Api::V1::AccountUsersController < PlatformController
|
|
|
|
before_action :set_resource
|
|
|
|
before_action :validate_platform_app_permissible
|
|
|
|
|
|
|
|
def index
|
|
|
|
render json: @resource.account_users
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@account_user = @resource.account_users.find_or_initialize_by(user_id: account_user_params[:user_id])
|
|
|
|
@account_user.update!(account_user_params)
|
|
|
|
render json: @account_user
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2022-03-24 07:58:25 +00:00
|
|
|
@resource.account_users.find_by(user_id: account_user_params[:user_id])&.destroy!
|
2021-01-14 15:05:22 +00:00
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_resource
|
|
|
|
@resource = Account.find(params[:account_id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def account_user_params
|
|
|
|
params.permit(:user_id, :role)
|
|
|
|
end
|
|
|
|
end
|