DEV: Deprecate the `modify_user_params` method in `UsersController` (#21740)

This commit deprecates the `modify_user_params` method in `UsersController` in favor of a new modifier that replaces that method whose entire purpose is to allow plugins to monkey-patch it to permit custom params in the controller. We now have the "modifier" system which can achieve the same results but in a safer and easier way. The modifier that replaces the deprecated method is included in PR https://github.com/discourse/discourse/pull/21737.
This commit is contained in:
Osama Sayegh 2023-05-25 09:56:06 +03:00 committed by GitHub
parent e8b138e24f
commit a048aeef6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -2014,6 +2014,7 @@ class UsersController < ApplicationController
result.merge!(params.permit(:active, :staged, :approved))
end
deprecate_modify_user_params_method
modify_user_params(result)
end
@ -2022,6 +2023,18 @@ class UsersController < ApplicationController
attrs
end
def deprecate_modify_user_params_method
# only issue a deprecation warning if the method is overriden somewhere
if method(:modify_user_params).source_location[0] !=
"#{Rails.root}/app/controllers/users_controller.rb"
Discourse.deprecate(
"`UsersController#modify_user_params` method is deprecated. Please use the `users_controller_update_user_params` modifier instead.",
since: "3.1.0.beta4",
drop_from: "3.2.0",
)
end
end
def fail_with(key)
render json: { success: false, message: I18n.t(key) }
end