X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e31376e28da8f656e33508cc899da465b63673c5..32d1afbb18ebde7fe9b5be37315fd384dadd0d6b:/app/controllers/user_roles_controller.rb diff --git a/app/controllers/user_roles_controller.rb b/app/controllers/user_roles_controller.rb index 2f5b5a84c..5ef68216b 100644 --- a/app/controllers/user_roles_controller.rb +++ b/app/controllers/user_roles_controller.rb @@ -10,12 +10,17 @@ class UserRolesController < ApplicationController before_action :in_role, :only => [:revoke] def grant - @this_user.roles.create(:role => @role, :granter_id => current_user.id) + @this_user.roles.create(:role => @role, :granter => current_user) redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end def revoke - UserRole.where(:user_id => @this_user.id, :role => @role).delete_all + # checks that administrator role is not revoked from current user + if current_user == @this_user && @role == "administrator" + flash[:error] = t("user_role.filter.not_revoke_admin_current_user") + else + UserRole.where(:user_id => @this_user.id, :role => @role).delete_all + end redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end