From 8f57514bc8782c90267f0cbcede4dcbfb51dd457 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Thu, 17 Sep 2020 18:21:58 -0500 Subject: [PATCH] Fixed issue with group fetching, serializer for loading password MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed: - issue with group fetching, serializer for loading password for admin only --- app/controllers/api/v1/groups_controller.rb | 2 +- app/serializers/rest/group_serializer.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/groups_controller.rb b/app/controllers/api/v1/groups_controller.rb index d35b02ff..e10f0e6e 100644 --- a/app/controllers/api/v1/groups_controller.rb +++ b/app/controllers/api/v1/groups_controller.rb @@ -61,7 +61,7 @@ class Api::V1::GroupsController < Api::BaseController end def show - render json: @group, serializer: REST::GroupSerializer + render json: @group, serializer: REST::GroupSerializer, individual_group: true end def create diff --git a/app/serializers/rest/group_serializer.rb b/app/serializers/rest/group_serializer.rb index 3c00908f..4f078cfd 100644 --- a/app/serializers/rest/group_serializer.rb +++ b/app/serializers/rest/group_serializer.rb @@ -20,8 +20,12 @@ class REST::GroupSerializer < ActiveModel::Serializer return nil end - if object.group_accounts.where(account_id: current_user.account.id, role: :admin).exists? - object.password + if instance_options[:individual_group] + if object.group_accounts.where(account_id: current_user.account.id, role: :admin).exists? + object.password + else + nil + end else nil end