From 352917995f10753be5674eb5c77e8b2d2da2f005 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Fri, 20 Sep 2019 12:58:21 -0400 Subject: [PATCH] Users without groups should use admin retirement Backport of https://github.com/ManageIQ/manageiq/pull/19309 Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1754043 --- app/models/mixins/retirement_mixin.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/mixins/retirement_mixin.rb b/app/models/mixins/retirement_mixin.rb index 7034d6389b63..df1cd1626b24 100644 --- a/app/models/mixins/retirement_mixin.rb +++ b/app/models/mixins/retirement_mixin.rb @@ -254,8 +254,12 @@ def valid_zone? def system_context_requester if try(:evm_owner_id).present? - if User.find_by(:id => evm_owner_id).present? + user = User.find_by(:id => evm_owner_id) + if user.present? && user.current_group.present? return evm_owner + elsif user.present? && !user.current_group.present? + $log.info("#{name} has evm_owner present but user has no group so defaulting to admin.") + return User.super_admin else $log.info("#{name} has evm_owner_id present but no user with that id found so defaulting to admin.") return User.super_admin