Add referer redirect
This commit is contained in:
parent
44ebf0ed8e
commit
3b13cf46c5
@ -397,11 +397,17 @@ get "/search" do |env|
|
|||||||
end
|
end
|
||||||
|
|
||||||
get "/login" do |env|
|
get "/login" do |env|
|
||||||
|
referer = env.request.headers["referer"]?
|
||||||
|
referer ||= "/feed/subscriptions"
|
||||||
|
|
||||||
templated "login"
|
templated "login"
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L79
|
# See https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L79
|
||||||
post "/login" do |env|
|
post "/login" do |env|
|
||||||
|
referer = env.params.query["referer"]?
|
||||||
|
referer ||= "/feed/subscriptions"
|
||||||
|
|
||||||
email = env.params.body["email"]?
|
email = env.params.body["email"]?
|
||||||
password = env.params.body["password"]?
|
password = env.params.body["password"]?
|
||||||
|
|
||||||
@ -465,8 +471,16 @@ post "/login" do |env|
|
|||||||
headers = login.cookies.add_request_headers(headers)
|
headers = login.cookies.add_request_headers(headers)
|
||||||
|
|
||||||
login = client.get(login.headers["Location"], headers)
|
login = client.get(login.headers["Location"], headers)
|
||||||
|
|
||||||
|
headers = HTTP::Headers.new
|
||||||
headers = login.cookies.add_request_headers(headers)
|
headers = login.cookies.add_request_headers(headers)
|
||||||
|
|
||||||
|
sid = login.cookies["SID"].value
|
||||||
|
|
||||||
|
client = get_client(youtube_pool)
|
||||||
|
user = get_user(sid, client, headers, PG_DB)
|
||||||
|
youtube_pool << client
|
||||||
|
|
||||||
# We are now logged in
|
# We are now logged in
|
||||||
|
|
||||||
host = URI.parse(env.request.headers["Host"]).host
|
host = URI.parse(env.request.headers["Host"]).host
|
||||||
@ -479,7 +493,7 @@ post "/login" do |env|
|
|||||||
|
|
||||||
login.cookies.add_response_headers(env.response.headers)
|
login.cookies.add_response_headers(env.response.headers)
|
||||||
|
|
||||||
env.redirect "/feed/subscriptions"
|
env.redirect referer
|
||||||
rescue ex
|
rescue ex
|
||||||
error_message = "Login failed"
|
error_message = "Login failed"
|
||||||
next templated "error"
|
next templated "error"
|
||||||
@ -487,12 +501,15 @@ post "/login" do |env|
|
|||||||
end
|
end
|
||||||
|
|
||||||
get "/signout" do |env|
|
get "/signout" do |env|
|
||||||
|
referer = env.request.headers["referer"]?
|
||||||
|
referer ||= "/"
|
||||||
|
|
||||||
env.request.cookies.each do |cookie|
|
env.request.cookies.each do |cookie|
|
||||||
cookie.expires = Time.new(1990, 1, 1)
|
cookie.expires = Time.new(1990, 1, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
env.request.cookies.add_response_headers(env.response.headers)
|
env.request.cookies.add_response_headers(env.response.headers)
|
||||||
env.redirect "/"
|
env.redirect referer
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/redirect" do |env|
|
get "/redirect" do |env|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="pure-u-1 pure-u-md-1-5"></div>
|
<div class="pure-u-1 pure-u-md-1-5"></div>
|
||||||
<div class="pure-u-1 pure-u-md-3-5">
|
<div class="pure-u-1 pure-u-md-3-5">
|
||||||
<div class="h-box">
|
<div class="h-box">
|
||||||
<form class="pure-form pure-form-stacked" action="/login" method="post">
|
<form class="pure-form pure-form-stacked" action="/login?referer=<%= referer %>" method="post">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Login to Google</legend>
|
<legend>Login to Google</legend>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user