Skip to content

A platform for community discussion. Free, open, simple.

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

Osama Sayegha048aeef6a3f
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c52ee650247..c857838c22e 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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