diff --git a/src/invidious.cr b/src/invidious.cr
index 8d50f815..3331d09f 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -340,6 +340,7 @@ get "/watch" do |env|
if env.params.query["v"].empty?
error_message = "Invalid parameters."
+ env.response.status_code = 400
next templated "error"
end
@@ -381,6 +382,7 @@ get "/watch" do |env|
next env.redirect "/watch?v=#{ex.message}"
rescue ex
error_message = ex.message
+ env.response.status_code = 500
logger.puts("#{id} : #{ex.message}")
next templated "error"
end
@@ -560,6 +562,7 @@ get "/embed/:id" do |env|
videos = fetch_playlist_videos(plid, 1, 1, locale: locale)
rescue ex
error_message = ex.message
+ env.response.status_code = 500
next templated "error"
end
@@ -602,6 +605,7 @@ get "/embed/:id" do |env|
next env.redirect "/embed/#{ex.message}"
rescue ex
error_message = ex.message
+ env.response.status_code = 500
next templated "error"
end
@@ -696,6 +700,7 @@ get "/playlist" do |env|
playlist = fetch_playlist(plid, locale)
rescue ex
error_message = ex.message
+ env.response.status_code = 500
next templated "error"
end
@@ -723,6 +728,7 @@ get "/mix" do |env|
mix = fetch_mix(rdid, continuation, locale: locale)
rescue ex
error_message = ex.message
+ env.response.status_code = 500
next templated "error"
end
@@ -843,6 +849,7 @@ get "/search" do |env|
duration: duration, features: features)
rescue ex
error_message = ex.message
+ env.response.status_code = 500
next templated "error"
end
@@ -864,6 +871,7 @@ get "/login" do |env|
if !config.login_enabled
error_message = "Login has been disabled by administrator."
+ env.response.status_code = 400
next templated "error"
end
@@ -892,6 +900,7 @@ post "/login" do |env|
if !config.login_enabled
error_message = "Login has been disabled by administrator."
+ env.response.status_code = 403
next templated "error"
end
@@ -965,11 +974,13 @@ post "/login" do |env|
if challenge_results[0][3]?.try &.== 7
error_message = translate(locale, "Account has temporarily been disabled")
+ env.response.status_code = 423
next templated "error"
end
if challenge_results[0][-1]?.try &.[5] == "INCORRECT_ANSWER_ENTERED"
error_message = translate(locale, "Incorrect password")
+ env.response.status_code = 401
next templated "error"
end
@@ -998,6 +1009,7 @@ post "/login" do |env|
if tfa[2] == "TWO_STEP_VERIFICATION"
if tfa[5] == "QUOTA_EXCEEDED"
error_message = translate(locale, "Quota exceeded, try again in a few hours")
+ env.response.status_code = 423
next templated "error"
end
@@ -1031,6 +1043,7 @@ post "/login" do |env|
}.to_json
else
error_message = translate(locale, "Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.")
+ env.response.status_code = 500
next templated "error"
end
@@ -1043,6 +1056,7 @@ post "/login" do |env|
if (challenge_results[0][-1]?.try &.[5] == "INCORRECT_ANSWER_ENTERED") ||
(challenge_results[0][-1]?.try &.[5] == "INVALID_INPUT")
error_message = translate(locale, "Invalid TFA code")
+ env.response.status_code = 401
next templated "error"
end
@@ -1117,16 +1131,19 @@ post "/login" do |env|
traceback.rewind
# error_message = translate(locale, "Login failed. This may be because two-factor authentication is not turned on for your account.")
error_message = %(#{ex.message}
Traceback: