diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 6661d71a91..09c860e4ed 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -169,11 +169,7 @@ def create_user_params end def update_user_params - @update_user_params ||= if external_auth? - params.require(:user).permit(:password, :avatar, :language, :role_id, :invite_token) - else - params.require(:user).permit(:name, :password, :avatar, :language, :role_id, :invite_token) - end + @update_user_params ||= params.require(:user).permit(permitted_params) end def change_password_params @@ -198,6 +194,14 @@ def valid_domain? end false end + + def permitted_params + is_admin = PermissionsChecker.new(current_user:, permission_names: 'ManageUsers', current_provider:).call + + return %i[password avatar language role_id invite_token] if external_auth? && !is_admin + + %i[name password avatar language role_id invite_token] + end end end end 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 (