]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/users/received_blocks_controller.rb
Merge pull request #5501 from openstreetmap/dependabot/npm_and_yarn/qs-6.14.0
[rails.git] / app / controllers / users / received_blocks_controller.rb
index a47b56a58c5e050d48754a40255b8520bade7ff3..6f6cabd26e070dbfcaabc77a7aec2341ce640f91 100644 (file)
@@ -12,6 +12,7 @@ module Users
 
     before_action :lookup_user
     before_action :check_database_readable
+    before_action :check_database_writable, :only => :destroy
 
     ##
     # shows a list of all the blocks on the given user
@@ -27,5 +28,21 @@ module Users
 
       render :partial => "user_blocks/page" if turbo_frame_request_id == "pagination"
     end
+
+    ##
+    # shows revoke all active blocks page
+    def edit; end
+
+    ##
+    # revokes all active blocks
+    def destroy
+      if params[:confirm]
+        @user.blocks.active.each { |block| block.revoke!(current_user) }
+        flash[:notice] = t ".flash"
+        redirect_to user_received_blocks_path(@user)
+      else
+        render :action => :edit
+      end
+    end
   end
 end