Redirect to referrer instead of root on locale set#743
Redirect to referrer instead of root on locale set#743cmrd-senya wants to merge 1 commit intospree-contrib:mainfrom
Conversation
|
We just found out that http referrer is being spoofed on some configuration and can't be used reliably to redirect back. Is it a good idea to use a parameter for the |
|
Hello @cmrd-senya , Can you try this solution? |
|
diff --git a/app/views/spree/locale/index.html.erb b/app/views/spree/locale/index.html.erb
index 0dd5e3e..a85b531 100644
--- a/app/views/spree/locale/index.html.erb
+++ b/app/views/spree/locale/index.html.erb
@@ -8,6 +8,12 @@
<%= select_tag(:switch_to_locale,
options_for_select(available_locales_options, I18n.locale),
class: 'form-control') %>
+
+ <%= hidden_field_tag :original_url %>
+ <script>
+ var input = document.getElementById("original_url");
+ input.value = location.href;
+ </script>
<noscript><%= submit_tag %></noscript>
</div>
<% end %>And then use this input value as a URL to redirect back. If you're okay with such approach, tell me and I can implement it. |
With this change when you change the locale you are redirected to the same page you've been before instead of root of the Rails application.