From 509ee971c75706c778080965d2fe04536090a2c1 Mon Sep 17 00:00:00 2001 From: Ali Hadi Mazeh Date: Wed, 20 Nov 2024 11:44:51 -0500 Subject: [PATCH] - `UpdateUserForm` checks if user is an external and if the current user signed in doesn't have Manage Users permissions - `external_account` method & attribute moved from current user serializer to user serializer --- .../components/users/user/forms/UpdateUserForm.jsx | 3 ++- app/serializers/current_user_serializer.rb | 6 +----- app/serializers/user_serializer.rb | 6 +++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/javascript/components/users/user/forms/UpdateUserForm.jsx b/app/javascript/components/users/user/forms/UpdateUserForm.jsx index 740f8d420f..d1db18bd43 100644 --- a/app/javascript/components/users/user/forms/UpdateUserForm.jsx +++ b/app/javascript/components/users/user/forms/UpdateUserForm.jsx @@ -70,7 +70,7 @@ export default function UpdateUserForm({ user }) { return (
- + { @@ -102,6 +102,7 @@ UpdateUserForm.propTypes = { name: PropTypes.string.isRequired, email: PropTypes.string.isRequired, provider: PropTypes.string.isRequired, + external_account: PropTypes.bool.isRequired, role: PropTypes.shape({ id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb index c29c5c16e4..e3d3c59241 100644 --- a/app/serializers/current_user_serializer.rb +++ b/app/serializers/current_user_serializer.rb @@ -17,16 +17,12 @@ # frozen_string_literal: true class CurrentUserSerializer < UserSerializer - attributes :signed_in, :permissions, :status, :external_account, :super_admin + attributes :signed_in, :permissions, :status, :super_admin def signed_in true end - def external_account - object.external_id? - end - def permissions RolePermission.joins(:permission) .where(role_id: object.role_id) diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index ff2d2c7339..4fbeb92c8e 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -19,7 +19,7 @@ class UserSerializer < ApplicationSerializer include Avatarable - attributes :id, :name, :email, :provider, :language, :avatar, :verified, :created_at + attributes :id, :name, :email, :provider, :language, :avatar, :verified, :created_at, :external_account belongs_to :role @@ -27,6 +27,10 @@ def language object.language.tr('_', '-') end + def external_account + object.external_id? + end + def avatar user_avatar(object) end