Skip to content

Commit 9df4fdc

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 9df4fdc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ def oic_local_login
126126
user.assign_attributes attributes
127127

128128
if user.save
129-
user.update_attribute(:admin, oic_session.admin?)
129+
unless oic_session.admin?.nil?
130+
user.update_attribute(:admin, oic_session.admin?)
131+
end
130132
oic_session.user_id = user.id
131133
oic_session.save!
132134
# after user creation just show "My Page" don't redirect to remember
@@ -140,7 +142,9 @@ def oic_local_login
140142
return invalid_credentials
141143
end
142144
else
143-
user.update_attribute(:admin, oic_session.admin?)
145+
unless oic_session.admin?.nil?
146+
user.update_attribute(:admin, oic_session.admin?)
147+
end
144148
oic_session.user_id = user.id
145149
oic_session.save!
146150
# redirect back to initial URL

0 commit comments

Comments
 (0)