Commit 1099eaa104f049aaa10737225c14843bf00844fd
1 parent
faeb05e7
Exists in
fix_last_path
Added redirect to last path before login
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
1 changed file
with
4 additions
and
8 deletions
Show diff stats
lib/omniauth/strategies/remote_user.rb
@@ -43,20 +43,16 @@ module OmniAuth | @@ -43,20 +43,16 @@ module OmniAuth | ||
43 | 43 | ||
44 | def __set_last_path(env,response) | 44 | def __set_last_path(env,response) |
45 | request = Rack::Request.new(env) | 45 | request = Rack::Request.new(env) |
46 | - puts "---#{request.path_info}--#{__last_path(env)}" | ||
47 | if not __last_path(env) | 46 | if not __last_path(env) |
48 | response.set_cookie(options.last_path_cookie, {value: request.path_info , path: "#{request.script_name}", httponly: true}) | 47 | response.set_cookie(options.last_path_cookie, {value: request.path_info , path: "#{request.script_name}", httponly: true}) |
49 | end | 48 | end |
50 | - response | ||
51 | end | 49 | end |
52 | 50 | ||
53 | def __return_last_path(env) | 51 | def __return_last_path(env) |
54 | - last_path = __last_path(env) | ||
55 | request = Rack::Request.new(env) | 52 | request = Rack::Request.new(env) |
56 | - response = Rack::Response.new | ||
57 | - if last_path | 53 | + response = redirect_if_not_logging_in(request, __last_path(env)) |
54 | + if response && __last_path(env) | ||
58 | response.delete_cookie(options.last_path_cookie , path: "#{request.script_name}" ) | 55 | response.delete_cookie(options.last_path_cookie , path: "#{request.script_name}" ) |
59 | - response.redirect last_path | ||
60 | response.finish | 56 | response.finish |
61 | end | 57 | end |
62 | end | 58 | end |
@@ -67,7 +63,7 @@ module OmniAuth | @@ -67,7 +63,7 @@ module OmniAuth | ||
67 | response = redirect_if_not_logging_in(request, request.path ) | 63 | response = redirect_if_not_logging_in(request, request.path ) |
68 | if response | 64 | if response |
69 | response.delete_cookie(options.remote_user_cookie , path: "#{request.script_name}" ) | 65 | response.delete_cookie(options.remote_user_cookie , path: "#{request.script_name}" ) |
70 | - response = __set_last_path(env,response) | 66 | + __set_last_path(env,response) |
71 | response.finish | 67 | response.finish |
72 | end | 68 | end |
73 | end | 69 | end |
@@ -77,7 +73,7 @@ module OmniAuth | @@ -77,7 +73,7 @@ module OmniAuth | ||
77 | response = redirect_if_not_logging_in(request,_auth_path(request) ) | 73 | response = redirect_if_not_logging_in(request,_auth_path(request) ) |
78 | if response | 74 | if response |
79 | response.set_cookie(options.remote_user_cookie, {value: uid, path: "#{request.script_name}", httponly: true}) | 75 | response.set_cookie(options.remote_user_cookie, {value: uid, path: "#{request.script_name}", httponly: true}) |
80 | - response = __set_last_path(env,response) | 76 | + __set_last_path(env,response) |
81 | response.finish | 77 | response.finish |
82 | end | 78 | end |
83 | end | 79 | end |