From f6c9a14e6370596daaabc82bde3a119a06d81f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= Date: Mon, 16 Nov 2015 14:57:38 +0100 Subject: [PATCH 1/2] [webui] Fix redirect after login for proxy mode, issue#1182 Conflicts: src/api/app/controllers/webui/user_controller.rb src/api/app/controllers/webui/webui_controller.rb --- src/api/app/controllers/webui/user_controller.rb | 6 ++---- src/api/app/controllers/webui/webui_controller.rb | 14 -------------- .../test/functional/webui/user_controller_test.rb | 6 ++++-- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/api/app/controllers/webui/user_controller.rb b/src/api/app/controllers/webui/user_controller.rb index 0623e106bba..c0830b18a9d 100644 --- a/src/api/app/controllers/webui/user_controller.rb +++ b/src/api/app/controllers/webui/user_controller.rb @@ -45,9 +45,6 @@ def do_login end unless User.current - return_to = return_path - reset_session - set_return_path(return_to) flash.now[:error] = 'Authentication failed' User.current = User.find_by_login('_nobody_') render :template => 'webui/user/login' @@ -56,7 +53,8 @@ def do_login flash[:success] = 'You are logged in now' session[:login] = User.current.login - return redirect_to(return_path) + redirect_back_or_to root_path + return end flash[:error] = 'Authentication failed' redirect_to :action => 'login' diff --git a/src/api/app/controllers/webui/webui_controller.rb b/src/api/app/controllers/webui/webui_controller.rb index 00ec41a8191..2a90d75fdd4 100644 --- a/src/api/app/controllers/webui/webui_controller.rb +++ b/src/api/app/controllers/webui/webui_controller.rb @@ -11,7 +11,6 @@ class Webui::WebuiController < ActionController::Base before_filter :setup_view_path before_filter :instantiate_controller_and_action_names - before_filter :set_return_to, except: [:do_login, :login] before_filter :reset_activexml, :authenticate before_filter :check_user before_filter :check_anonymous @@ -90,21 +89,8 @@ class MissingParameterError < Exception; end render file: Rails.root.join('public/404'), status: 404, layout: false, formats: [:html] end - def return_path - session[:return_path] || root_path - end - - def set_return_path(path) - session[:return_path] = path unless request.xhr? - end - protected - def set_return_to - set_return_path(request.env['ORIGINAL_FULLPATH']) - logger.debug "Setting return_to: '#{return_path}'" - end - # Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to() def redirect_back_or_to(options = {}, response_status = {}) if request.env['HTTP_REFERER'] diff --git a/src/api/test/functional/webui/user_controller_test.rb b/src/api/test/functional/webui/user_controller_test.rb index 03ae405cee2..0a21bcb61db 100644 --- a/src/api/test/functional/webui/user_controller_test.rb +++ b/src/api/test/functional/webui/user_controller_test.rb @@ -72,13 +72,15 @@ def test_show_user_page end def test_that_redirect_after_login_works + use_js + visit search_path - visit user_login_path + click_link("Log In") fill_in 'Username', with: "tom" fill_in 'Password', with: "thunder" click_button 'Log In' - assert_equal "tom", User.current.try(:login) + assert_equal "tom", find('#link-to-user-home').text assert_equal search_path, current_path end end From badece67654e60704934902295b0a5efc03bae11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= Date: Wed, 18 Nov 2015 13:02:09 +0100 Subject: [PATCH 2/2] [webui] Fix redirect after login for IChain mode, issue#1182 This provides a redirect url which IChain can use to properly redirect to OBS. Otherwise this would always redirect to the main page. --- src/api/app/views/layouts/webui/_personal_navigation.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/app/views/layouts/webui/_personal_navigation.html.erb b/src/api/app/views/layouts/webui/_personal_navigation.html.erb index 83e6acbda3f..b9be2731e25 100644 --- a/src/api/app/views/layouts/webui/_personal_navigation.html.erb +++ b/src/api/app/views/layouts/webui/_personal_navigation.html.erb @@ -27,6 +27,7 @@ <%= hidden_field_tag(:context, 'default') %> <%= hidden_field_tag(:proxypath, 'reserve') %> <%= hidden_field_tag(:message, 'Please log in') %> + <%= hidden_field_tag(:url, request.fullpath) %> <%= label_tag(:username, 'Username') %> <%= text_field_tag(:username, '') %>