Bug #7253
closedunable to modify user in UI as it incorrectly states "Administrator cannot be removed from the last admin account"
Description
The bit of code in app/model/user.rb ensure_last_admin_remains_admin()
!new_record? && admin_changed? && !admin && User.unscoped.only_admin.except_hidden.size <= 1
evaluates (incorrectly) to true.
User.unscoped.only_admin.except_hidden.size = 1
Why is more than one admin required?
Updated by Dominic Cleal over 10 years ago
- Status changed from New to Feedback
Under what conditions is this a problem? Any user? Any non-admin user? When only one admin user is present? Please provide reproducer steps.
At least one admin is required to retain administrative level access, else recovery methods are required to regain access.
Updated by Thomas McKay over 10 years ago
- Status changed from Feedback to New
I have one admin and when I edit users in the UI, it errors due to that line preventing any modification of users.
Updated by Dominic Cleal over 10 years ago
- Target version set to 1.7.4
- Translation missing: en.field_release set to 22
Reproducer:
1. create a non-admin user via the API (or another means, not the UI)
2. ensure the admin field is nil, not false:
2.0.0-p353 :001 > User.find_by_login("wraptest5").admin? => false 2.0.0-p353 :002 > User.find_by_login("wraptest5").admin => nil
3. as an admin, edit the non-admin user
This means "admin_changed?" results in true as it moves from nil to false, rather than false to true as the expression was intended to catch.
[1] pry(#<User>)> changes => {"admin"=>[nil, false], ...
Updated by Dominic Cleal over 10 years ago
- Status changed from New to Assigned
- Assignee set to Dominic Cleal
- Translation missing: en.field_release changed from 22 to 10
Updated by The Foreman Bot over 10 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/1749 added
- Pull request deleted (
)
Updated by Dominic Cleal over 10 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset b8391adc2f720734551c57af96a2a50b9699fb58.