Prevent CSRF bypass unblocking users
This commit is contained in:
parent
7810734ac4
commit
c49e400aa3
2 changed files with 9 additions and 2 deletions
|
@ -79,7 +79,7 @@ class UserBlocksController < ApplicationController
|
|||
##
|
||||
# revokes the block, setting the end_time to now
|
||||
def revoke
|
||||
if params[:confirm] && @user_block.revoke!(current_user)
|
||||
if request.post? && params[:confirm] && @user_block.revoke!(current_user)
|
||||
flash[:notice] = t ".flash"
|
||||
redirect_to(@user_block)
|
||||
end
|
||||
|
|
|
@ -351,7 +351,14 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_select "input[type='submit'][value='Revoke!']", :count => 1
|
||||
end
|
||||
|
||||
# Check that revoking a block works
|
||||
# Check that revoking a block using GET should fail
|
||||
get revoke_user_block_path(:id => active_block, :confirm => true)
|
||||
assert_response :success
|
||||
assert_template "revoke"
|
||||
b = UserBlock.find(active_block.id)
|
||||
assert b.ends_at - Time.now > 100
|
||||
|
||||
# Check that revoking a block works using POST
|
||||
post revoke_user_block_path(:id => active_block, :confirm => true)
|
||||
assert_redirected_to user_block_path(active_block)
|
||||
b = UserBlock.find(active_block.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue