mirror of
https://github.com/iv-org/invidious
synced 2024-11-10 21:23:34 +01:00
Don't redirect to current page
This commit is contained in:
parent
6d8caaee65
commit
c09b41a8f8
@ -402,8 +402,7 @@ get "/login" do |env|
|
|||||||
next env.redirect "/feed/subscriptions"
|
next env.redirect "/feed/subscriptions"
|
||||||
end
|
end
|
||||||
|
|
||||||
referer = env.request.headers["referer"]?
|
referer = get_referer(env, "/feed/subscriptions")
|
||||||
referer ||= "/feed/subscriptions"
|
|
||||||
|
|
||||||
account_type = env.params.query["type"]?
|
account_type = env.params.query["type"]?
|
||||||
account_type ||= "invidious"
|
account_type ||= "invidious"
|
||||||
@ -415,21 +414,13 @@ get "/login" do |env|
|
|||||||
tfa = env.params.query["tfa"]?
|
tfa = env.params.query["tfa"]?
|
||||||
tfa ||= false
|
tfa ||= false
|
||||||
|
|
||||||
if referer.ends_with? "/login"
|
|
||||||
referer = "/feed/subscriptions"
|
|
||||||
end
|
|
||||||
|
|
||||||
if referer.size > 64
|
|
||||||
referer = "/feed/subscriptions"
|
|
||||||
end
|
|
||||||
|
|
||||||
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 = env.params.query["referer"]?
|
||||||
referer ||= "/feed/subscriptions"
|
referer ||= get_referer(env, "/feed/subscriptions")
|
||||||
|
|
||||||
email = env.params.body["email"]?
|
email = env.params.body["email"]?
|
||||||
password = env.params.body["password"]?
|
password = env.params.body["password"]?
|
||||||
@ -681,8 +672,7 @@ post "/login" do |env|
|
|||||||
end
|
end
|
||||||
|
|
||||||
get "/signout" do |env|
|
get "/signout" do |env|
|
||||||
referer = env.request.headers["referer"]?
|
referer = get_referer(env)
|
||||||
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)
|
||||||
@ -695,26 +685,20 @@ end
|
|||||||
get "/preferences" do |env|
|
get "/preferences" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
|
||||||
referer = env.request.headers["referer"]?
|
referer = get_referer(env)
|
||||||
referer ||= "/preferences"
|
|
||||||
|
|
||||||
if referer.size > 64
|
|
||||||
referer = "/preferences"
|
|
||||||
end
|
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
templated "preferences"
|
templated "preferences"
|
||||||
else
|
else
|
||||||
env.redirect "/"
|
env.redirect referer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
post "/preferences" do |env|
|
post "/preferences" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
|
||||||
referer = env.params.query["referer"]?
|
referer = get_referer(env)
|
||||||
referer ||= "/preferences"
|
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -801,8 +785,7 @@ end
|
|||||||
get "/toggle_theme" do |env|
|
get "/toggle_theme" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
|
||||||
referer = env.params.query["referer"]?
|
referer = get_referer(env)
|
||||||
referer ||= "/feed/subscriptions"
|
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -827,8 +810,7 @@ end
|
|||||||
get "/modify_notifications" do |env|
|
get "/modify_notifications" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
|
||||||
referer = env.request.headers["referer"]?
|
referer = get_referer(env)
|
||||||
referer ||= "/"
|
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -874,8 +856,10 @@ end
|
|||||||
get "/subscription_manager" do |env|
|
get "/subscription_manager" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
|
||||||
|
referer = get_referer(env, "/")
|
||||||
|
|
||||||
if !user
|
if !user
|
||||||
next env.redirect "/"
|
next env.redirect referer
|
||||||
end
|
end
|
||||||
|
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -956,8 +940,8 @@ end
|
|||||||
|
|
||||||
get "/data_control" do |env|
|
get "/data_control" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
referer = env.request.headers["referer"]?
|
|
||||||
referer ||= "/"
|
referer = get_referer(env)
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -970,8 +954,8 @@ end
|
|||||||
|
|
||||||
post "/data_control" do |env|
|
post "/data_control" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
referer = env.request.headers["referer"]?
|
|
||||||
referer ||= "/"
|
referer = get_referer(env)
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -1079,11 +1063,8 @@ end
|
|||||||
|
|
||||||
get "/subscription_ajax" do |env|
|
get "/subscription_ajax" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
referer = env.request.headers["referer"]?
|
|
||||||
|
|
||||||
if !referer || URI.parse(referer).path.try &.== "/subscription_ajax"
|
referer = get_referer(env)
|
||||||
referer = "/"
|
|
||||||
end
|
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -1154,8 +1135,8 @@ end
|
|||||||
|
|
||||||
get "/clear_watch_history" do |env|
|
get "/clear_watch_history" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
referer = env.request.headers["referer"]?
|
|
||||||
referer ||= "/"
|
referer = get_referer(env)
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -1170,6 +1151,7 @@ end
|
|||||||
|
|
||||||
get "/feed/subscriptions" do |env|
|
get "/feed/subscriptions" do |env|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
referer = get_referer(env)
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
@ -1289,7 +1271,7 @@ get "/feed/subscriptions" do |env|
|
|||||||
|
|
||||||
templated "subscriptions"
|
templated "subscriptions"
|
||||||
else
|
else
|
||||||
env.redirect "/"
|
env.redirect referer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,3 +148,16 @@ def make_host_url(ssl, host)
|
|||||||
|
|
||||||
return "#{scheme}#{host}"
|
return "#{scheme}#{host}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_referer(env, fallback = "/")
|
||||||
|
referer = env.request.headers["referer"]?
|
||||||
|
referer ||= fallback
|
||||||
|
|
||||||
|
referer = URI.parse(referer).full_path
|
||||||
|
|
||||||
|
if referer == env.request.path
|
||||||
|
referer = fallback
|
||||||
|
end
|
||||||
|
|
||||||
|
return referer
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user