Skip to content

Commit

Permalink
[webui] Fix redirect after login for proxy mode, issue#1182
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Nov 17, 2015
1 parent 54fa05d commit ca052c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/api/app/controllers/webui/user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def do_login
end

if user.nil? || (user.state == User::STATES['ichainrequest'] || user.state == User::STATES['unconfirmed'])
set_return_path(return_path)
redirect_to(user_login_path, error: 'Authentication failed')
return
end
Expand All @@ -53,7 +52,7 @@ def do_login
session[:login] = User.current.login
session[:password] = params[:password]

redirect_to(return_path)
redirect_back_or_to root_path
end

def show
Expand Down
14 changes: 0 additions & 14 deletions src/api/app/controllers/webui/webui_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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, :register_user]
before_filter :check_user
before_filter :check_anonymous
before_filter :require_configuration
Expand Down Expand Up @@ -95,14 +94,6 @@ 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

def set_project
@project = Project.find_by(name: params[:project])
raise ActiveRecord::RecordNotFound unless @project
Expand All @@ -114,11 +105,6 @@ def set_project_by_id

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']
Expand Down
6 changes: 4 additions & 2 deletions src/api/test/functional/webui/user_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,15 @@ def test_that_require_admin_works
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

Expand Down

0 comments on commit ca052c7

Please sign in to comment.