From 1099eaa104f049aaa10737225c14843bf00844fd Mon Sep 17 00:00:00 2001 From: Macartur Sousa Date: Wed, 22 Jul 2015 14:03:30 -0300 Subject: [PATCH] Added redirect to last path before login --- lib/omniauth/strategies/remote_user.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/omniauth/strategies/remote_user.rb b/lib/omniauth/strategies/remote_user.rb index faf4d66..d4eca87 100644 --- a/lib/omniauth/strategies/remote_user.rb +++ b/lib/omniauth/strategies/remote_user.rb @@ -43,20 +43,16 @@ module OmniAuth def __set_last_path(env,response) request = Rack::Request.new(env) - puts "---#{request.path_info}--#{__last_path(env)}" if not __last_path(env) response.set_cookie(options.last_path_cookie, {value: request.path_info , path: "#{request.script_name}", httponly: true}) end - response end def __return_last_path(env) - last_path = __last_path(env) request = Rack::Request.new(env) - response = Rack::Response.new - if last_path + response = redirect_if_not_logging_in(request, __last_path(env)) + if response && __last_path(env) response.delete_cookie(options.last_path_cookie , path: "#{request.script_name}" ) - response.redirect last_path response.finish end end @@ -67,7 +63,7 @@ module OmniAuth response = redirect_if_not_logging_in(request, request.path ) if response response.delete_cookie(options.remote_user_cookie , path: "#{request.script_name}" ) - response = __set_last_path(env,response) + __set_last_path(env,response) response.finish end end @@ -77,7 +73,7 @@ module OmniAuth response = redirect_if_not_logging_in(request,_auth_path(request) ) if response response.set_cookie(options.remote_user_cookie, {value: uid, path: "#{request.script_name}", httponly: true}) - response = __set_last_path(env,response) + __set_last_path(env,response) response.finish end end -- libgit2 0.21.2