Skip to content

Commit 8ae0f90

Browse files
committed
Make admin attribute update optional
If the admin_group configuration is not declared, skip the update of admin flags. This prevents dropping of the admin flag from users in environments without IDP based admin roles. Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
1 parent 470de18 commit 8ae0f90

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/models/oic_session.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ def authorized?
159159
end
160160

161161
def admin?
162+
if client_config['admin_group'].empty?
163+
return nil
164+
end
162165
if client_config['admin_group'].present?
163166
if user["member_of"].present?
164167
return true if user["member_of"].include?(client_config['admin_group'])

lib/redmine_openid_connect/account_controller_patch.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def oic_local_login
140140
return invalid_credentials
141141
end
142142
else
143-
user.update_attribute(:admin, oic_session.admin?)
143+
unless oic_session.admin?.nil?
144+
user.update_attribute(:admin, oic_session.admin?)
145+
end
144146
oic_session.user_id = user.id
145147
oic_session.save!
146148
# redirect back to initial URL

0 commit comments

Comments
 (0)