Skip to content

Commit 8141bde

Browse files
committed
Fix handling of attrs[:managed] on Org updates
This change resolves issue #3528 by preventing the updating of `@org.managed` when `attrs[:managed]` is missing. Prior to this change, the `if attrs.key?(:managed)` was not present. But it was necessary, because that key is not present when a super user clicks "Save" on the "Request Feedback" page. - As a result, if `attrs[:managed]` was not present, then `attrs[:managed] = (attrs[:managed] == '1')` would evaluate false, and `if @org.update(attrs)` (line 81) would subsequently update `@org.managed` to false in the db.
1 parent f7bcd33 commit 8141bde

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/controllers/orgs_controller.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def admin_update
4444
# Only allow super admins to change the org types and shib info
4545
if current_user.can_super_admin?
4646
identifiers = []
47-
attrs[:managed] = attrs[:managed] == '1'
47+
attrs = handle_managed_flag(attrs)
4848

4949
# Handle Shibboleth identifier if that is enabled
5050
if Rails.configuration.x.shibboleth.use_filtered_discovery_service
@@ -236,6 +236,13 @@ def search_params
236236
params.require(:org).permit(:name, :type)
237237
end
238238

239+
def handle_managed_flag(attrs)
240+
# NOTE: `:managed` is controlled by a check_box in the form
241+
# `app/views/orgs/_profile_form.html.erb`.
242+
attrs[:managed] = (attrs[:managed] == '1') if attrs.key?(:managed)
243+
attrs
244+
end
245+
239246
def shib_login_url
240247
shib_login = Rails.configuration.x.shibboleth.login_url
241248
"#{request.base_url.gsub('http:', 'https:')}#{shib_login}"

0 commit comments

Comments
 (0)