Skip to content

Commit

Permalink
authorize_user! returns 403 if request.xhr? == true
Browse files Browse the repository at this point in the history
  • Loading branch information
y-sugawara-acs committed Sep 9, 2024
1 parent 27b5f3b commit 9757e74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## main
* Ruby 2.6 のサポート復活
* Bizside::Acl::ControllerHelper
* authorize_user! で x-requested-with ヘッダに "XMLHttpRequest" という文字列(大文字小文字区別なし)が含まれていた場合 root_path にリダイレクトではなく 403 を返却

## 3.0.0
* Ruby 2.5 のサポート廃止
Expand Down
7 changes: 5 additions & 2 deletions lib/bizside/acl/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ module ControllerHelper
include Bizside::Acl::AvailableHelper

def authorize_user!
unless available_for(params[:controller], params[:action], params)
return if available_for(params[:controller], params[:action], params)

if request.xhr?
head :forbidden
else
redirect_to root_path
return
end
end

Expand Down

0 comments on commit 9757e74

Please sign in to comment.