Commit 1f021975c401e59d451af9df249fd6599f84d6a6
1 parent
e3f2222d
Exists in
fix_last_path
Fixed redirect to use last request_path
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
1 changed file
with
8 additions
and
3 deletions
Show diff stats
lib/omniauth/strategies/remote_user.rb
... | ... | @@ -41,17 +41,22 @@ module OmniAuth |
41 | 41 | request.cookies.has_key?(options.last_path_cookie) && request.cookies[options.last_path_cookie] |
42 | 42 | end |
43 | 43 | |
44 | + def __request_path(env) | |
45 | + env['REQUEST_PATH'] | |
46 | + end | |
47 | + | |
44 | 48 | def __set_last_path(env,response) |
45 | 49 | request = Rack::Request.new(env) |
46 | 50 | if not __last_path(env) |
47 | - response.set_cookie(options.last_path_cookie, {value: request.path_info , path: "#{request.script_name}", httponly: true}) | |
51 | + response.set_cookie(options.last_path_cookie, {value: __request_path(env) , path: "#{request.script_name}"}) | |
48 | 52 | end |
49 | 53 | end |
50 | 54 | |
51 | 55 | def __return_last_path(env) |
52 | 56 | request = Rack::Request.new(env) |
53 | - response = redirect_if_not_logging_in(request, __last_path(env)) | |
54 | - if response && __last_path(env) | |
57 | + if ! [_auth_path(request),_callback_path(request)].include?(__request_path(env)) && __last_path(env) | |
58 | + response = Rack::Response.new | |
59 | + response.redirect __last_path(env) | |
55 | 60 | response.delete_cookie(options.last_path_cookie , path: "#{request.script_name}" ) |
56 | 61 | response.finish |
57 | 62 | end | ... | ... |