Make shopfront redirect work when logging out by storing it outside session data

This commit is contained in:
Luis Ramos
2020-07-06 17:51:19 +01:00
parent 86afa6f413
commit 7c498a573c
2 changed files with 15 additions and 1 deletions

View File

@@ -62,11 +62,15 @@ class ApplicationController < ActionController::Base
end
def after_sign_out_path_for(_resource_or_scope)
session[:shopfront_redirect] || main_app.root_path
shopfront_redirect || main_app.root_path
end
private
def shopfront_redirect
session[:shopfront_redirect]
end
def restrict_iframes
response.headers['X-Frame-Options'] = 'DENY'
response.headers['Content-Security-Policy'] = "frame-ancestors 'none'"

View File

@@ -39,8 +39,18 @@ module Spree
end
end
def destroy
# Logout will clear session data including shopfront_redirect
# Here we store it before actually logging out so that the redirect works correctly
@shopfront_redirect = session[:shopfront_redirect]
super
end
private
attr_reader :shopfront_redirect
def accurate_title
Spree.t(:login)
end