summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-26 08:46:33 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-26 08:46:33 +0000
commit9f92554319144effbab13b688b07d15cdafea89a (patch)
tree4deda817a75d68caef0cb2fd205766dc68ea01db /app/controllers
parent5564dfbbd5a31362fde86f27ac8beccd1661d6f8 (diff)
downloadredmine-9f92554319144effbab13b688b07d15cdafea89a.tar.gz
redmine-9f92554319144effbab13b688b07d15cdafea89a.zip
Redirect user to the previous page after logging in (#1679).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1695 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application.rb25
1 files changed, 11 insertions, 14 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 2daee50de..debe02162 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -15,6 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+require 'uri'
+
class ApplicationController < ActionController::Base
before_filter :user_setup, :check_if_login_required, :set_localization
filter_parameter_logging :password
@@ -77,8 +79,7 @@ class ApplicationController < ActionController::Base
def require_login
if !User.current.logged?
- store_location
- redirect_to :controller => "account", :action => "login"
+ redirect_to :controller => "account", :action => "login", :back_url => request.request_uri
return false
end
true
@@ -115,20 +116,16 @@ class ApplicationController < ActionController::Base
end
end
- # store current uri in session.
- # return to this location by calling redirect_back_or_default
- def store_location
- session[:return_to_params] = params
- end
-
- # move to the last store_location call or to the passed default one
def redirect_back_or_default(default)
- if session[:return_to_params].nil?
- redirect_to default
- else
- redirect_to session[:return_to_params]
- session[:return_to_params] = nil
+ back_url = params[:back_url]
+ if !back_url.blank?
+ uri = URI.parse(back_url)
+ # do not redirect user to another host
+ if uri.relative? || (uri.host == request.host)
+ redirect_to(back_url) and return
+ end
end
+ redirect_to default
end
def render_403