end
def new
+ default = home_url
if params[:return_to]
# user clicked on the link "login" : redirect to the original uri after authentication
- session[:return_to] = Api::Utils.absolute_to_relative_url(params[:return_to])
- return_to = Api::Utils.absolute_to_relative_url(params[:return_to])
+ default = Api::Utils.absolute_to_relative_url(params[:return_to])
# else the original uri can be set by ApplicationController#access_denied
end
- @return_to = get_redirect_back_or_default(home_url)
+ @return_to = get_redirect_back_or_default(default)
end
private
# Get redirection to the URI stored by the most recent store_location call or to the passed default.
def get_redirect_back_or_default(default)
# Prevent CSRF attack -> do not accept absolute urls
- url = session[:return_to] || default
+ url = get_cookie_flash('return_to') || default
begin
url = URI(url).request_uri
rescue
<form action="<%= url_for :controller => 'users', :action => 'signup' -%>" method="post">
- <input type="hidden" name="return_to_anchor" value="">
<h1 class="maintenance-title text-center">Sign Up to SonarQube</h1>
#
# We can return to this location by calling #redirect_back_or_default.
def store_location
- session[:return_to] = request.request_uri
+ flash[:return_to] = request.request_uri
end
# Redirect to the URI stored by the most recent store_location call or
# for any controller you want to be bounce-backable.
def redirect_back_or_default(default)
# Prevent CSRF attack -> do not accept absolute urls
- url = session[:return_to] || default
+ url = get_cookie_flash('return_to') || default
begin
url = URI(url).request_uri
rescue
anchor=params[:return_to_anchor]
url += anchor if anchor && anchor.start_with?('#')
redirect_to(url)
- session[:return_to] = nil
end
# Inclusion hook to make #current_user and #logged_in?
end
end
+ def get_cookie_flash(key)
+ cflash = (JSON.parse(cookies['flash']) if cookies['flash']) || {} rescue {}
+ cflash[key]
+ end
+
# @parameters
# cookies -
# There might be crusty flash from a previous request, or set elsewhere, already in the cookie.