mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix checkout confirmation page blank (access denied) when checking out anonymously - BugHerd #139
This commit is contained in:
@@ -20,10 +20,16 @@ Spree::CheckoutController.class_eval do
|
||||
|
||||
def after_complete
|
||||
distributor = current_order.distributor
|
||||
token = current_order.token
|
||||
|
||||
session[:order_id] = nil
|
||||
clear_current_order_cache
|
||||
current_order(true)
|
||||
|
||||
current_order.set_distributor!(distributor)
|
||||
current_order.tokenized_permission.token = token
|
||||
current_order.tokenized_permission.save!
|
||||
session[:access_token] = token
|
||||
end
|
||||
|
||||
def clear_current_order_cache
|
||||
|
||||
@@ -26,5 +26,14 @@ describe Spree::CheckoutController do
|
||||
controller.current_order.distributor.should == distributor
|
||||
end
|
||||
|
||||
it "should set the new order's token to the same as the old order, and preserve the access token in the session" do
|
||||
order = controller.current_order(true)
|
||||
|
||||
controller.send(:after_complete)
|
||||
|
||||
controller.current_order.token.should == order.token
|
||||
session[:access_token].should == order.token
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user