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 | 43 | |
| 44 | 44 | def __set_last_path(env,response) |
| 45 | 45 | request = Rack::Request.new(env) |
| 46 | - puts "---#{request.path_info}--#{__last_path(env)}" | |
| 47 | 46 | if not __last_path(env) |
| 48 | 47 | response.set_cookie(options.last_path_cookie, {value: request.path_info , path: "#{request.script_name}", httponly: true}) |
| 49 | 48 | end |
| 50 | - response | |
| 51 | 49 | end |
| 52 | 50 | |
| 53 | 51 | def __return_last_path(env) |
| 54 | - last_path = __last_path(env) | |
| 55 | 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 | 55 | response.delete_cookie(options.last_path_cookie , path: "#{request.script_name}" ) |
| 59 | - response.redirect last_path | |
| 60 | 56 | response.finish |
| 61 | 57 | end |
| 62 | 58 | end |
| ... | ... | @@ -67,7 +63,7 @@ module OmniAuth |
| 67 | 63 | response = redirect_if_not_logging_in(request, request.path ) |
| 68 | 64 | if response |
| 69 | 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 | 67 | response.finish |
| 72 | 68 | end |
| 73 | 69 | end |
| ... | ... | @@ -77,7 +73,7 @@ module OmniAuth |
| 77 | 73 | response = redirect_if_not_logging_in(request,_auth_path(request) ) |
| 78 | 74 | if response |
| 79 | 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 | 77 | response.finish |
| 82 | 78 | end |
| 83 | 79 | end | ... | ... |