Skip to content

Commit

Permalink
Spec helper fixes to work with SESSIONS/RODA_ROUTE_CSRF environment v…
Browse files Browse the repository at this point in the history
…ariables
  • Loading branch information
jeremyevans committed Nov 19, 2024
1 parent bc116db commit 6bfb93d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def roda(type=nil, &block)
opts[:json] = jwt_only ? :only : true
end

if type == :no_csrf
if type == :no_csrf || (!USE_ROUTE_CSRF && (json || jwt))
opts[:csrf] = false
end

Expand Down Expand Up @@ -257,7 +257,9 @@ def roda(type=nil, &block)
if USE_ROUTE_CSRF == :always && !json && opts[:csrf] != false
orig_block = block
block = proc do |r|
check_csrf!
unless env["CONTENT_TYPE"] == "application/json" || (jwt_enable && rodauth.use_jwt?)
check_csrf!
end
instance_exec(r, &orig_block)
end
end
Expand Down

0 comments on commit 6bfb93d

Please sign in to comment.