|
|
@ -164,6 +164,14 @@ spawn do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before_all do |env|
|
|
|
|
|
|
|
|
if env.request.cookies["SID"]?
|
|
|
|
|
|
|
|
env.set "authorized", true
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
env.set "authorized", false
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
get "/" do |env|
|
|
|
|
get "/" do |env|
|
|
|
|
templated "index"
|
|
|
|
templated "index"
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -409,9 +417,15 @@ post "/login" do |env|
|
|
|
|
|
|
|
|
|
|
|
|
login = client.get(login.headers["Location"], headers)
|
|
|
|
login = client.get(login.headers["Location"], headers)
|
|
|
|
headers = login.cookies.add_request_headers(headers)
|
|
|
|
headers = login.cookies.add_request_headers(headers)
|
|
|
|
|
|
|
|
|
|
|
|
# We are now logged in
|
|
|
|
# We are now logged in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
login.cookies.each do |cookie|
|
|
|
|
|
|
|
|
host = URI.parse(env.request.headers["Host"]).host
|
|
|
|
|
|
|
|
cookie.extension = cookie.extension.not_nil!.gsub(".youtube.com", host)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
login.cookies.add_response_headers(env.response.headers)
|
|
|
|
|
|
|
|
|
|
|
|
env.redirect "/"
|
|
|
|
env.redirect "/"
|
|
|
|
rescue ex
|
|
|
|
rescue ex
|
|
|
|
error_message = "Login failed"
|
|
|
|
error_message = "Login failed"
|
|
|
@ -419,6 +433,15 @@ post "/login" do |env|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get "/logout" do |env|
|
|
|
|
|
|
|
|
env.request.cookies.each do |cookie|
|
|
|
|
|
|
|
|
cookie.expires = Time.new(1990, 1, 1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
env.request.cookies.add_response_headers(env.response.headers)
|
|
|
|
|
|
|
|
env.redirect "/"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
get "/redirect" do |env|
|
|
|
|
get "/redirect" do |env|
|
|
|
|
if env.params.query["q"]?
|
|
|
|
if env.params.query["q"]?
|
|
|
|
env.redirect env.params.query["q"]
|
|
|
|
env.redirect env.params.query["q"]
|
|
|
|