diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb index 2b54cc5e..7c6f60f0 100644 --- a/app/controllers/admin/object_auths_controller.rb +++ b/app/controllers/admin/object_auths_controller.rb @@ -19,53 +19,50 @@ class Admin::ObjectAuthsController < ApplicationController # end end - def create - # app_auth = AppAuth.find_or_create_by(module_app_id: params[:module_app_id]) - # params[:new].each do |item| - # field = item[0] - # field_value = item[1] - # if field_value!='' - # case field - # when 'role' - # app_auth.send("add_#{field}",(Role.find field_value)) rescue nil - # when 'sub_role' - # app_auth.send("add_#{field}",(SubRole.find field_value)) rescue nil - # when 'privilege_user' - # app_auth.add_user_to_privilege_list (User.find field_value) rescue nil - # when 'blocked_user' - # app_auth.add_user_to_black_list (User.find field_value) rescue nil - # end - # end - # end - # app = ModuleApp.find params[:module_app_id] rescue nil - # redirect_to edit_admin_module_app_path(app) - end + def create_role + object_auth = ObjectAuth.find(params[:id]) + params[:new].each do |item| + field = item[0] + field_value = item[1] + if field_value!='' + case field + when 'role' + object_auth.send("add_#{field}",(Role.find field_value)) rescue nil + when 'sub_role' + object_auth.send("add_#{field}",(SubRole.find field_value)) rescue nil + when 'privilege_user' + object_auth.add_user_to_privilege_list (User.find field_value) rescue nil + when 'blocked_user' + object_auth.add_user_to_black_list (User.find field_value) rescue nil + end + end + end + redirect_to edit_admin_object_auth_path(object_auth) + end - def remove - # app_auth = AppAuth.find( params[:id] ) - # type = params[:type] - # field_value = params[:target_id] - # if field_value!='' - # case type - # when 'role' - # app_auth.remove_role(Role.find field_value) rescue nil - # when 'sub_role' - # app_auth.remove_sub_role(SubRole.find field_value) rescue nil - # when 'privilege_user' - # app_auth.remove_user_from_privilege_list (User.find field_value) rescue nil - # when 'blocked_user' - # app_auth.remove_user_from_black_list (User.find field_value) rescue nil - # end - # end - # - # app = ModuleApp.find params[:module_app_id] rescue nil - # redirect_to edit_admin_module_app_path(app) + def remove_role + object_auth = ObjectAuth.find(params[:id]) + type = params[:type] + field_value = params[:target_id] + if field_value!='' + case type + when 'role' + object_auth.remove_role(Role.find field_value) rescue nil + when 'sub_role' + object_auth.remove_sub_role(SubRole.find field_value) rescue nil + when 'privilege_user' + object_auth.remove_user_from_privilege_list (User.find field_value) rescue nil + when 'blocked_user' + object_auth.remove_user_from_black_list (User.find field_value) rescue nil + end + end + redirect_to edit_admin_object_auth_path(object_auth) end def edit @object_auth = ObjectAuth.find(params[:id]) end - + end \ No newline at end of file diff --git a/app/views/admin/components/_user_role_management.html.erb b/app/views/admin/components/_user_role_management.html.erb index 7afca0a4..59307351 100644 --- a/app/views/admin/components/_user_role_management.html.erb +++ b/app/views/admin/components/_user_role_management.html.erb @@ -1,8 +1,6 @@