From cd482cfd8930b11d04329c91f46ee2a1b5f08ca8 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 17 Nov 2018 13:26:24 -0600 Subject: [PATCH] Add more informative error response on incorrect CAPTCHA --- src/invidious.cr | 7 ++++++- src/invidious/users.cr | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 88663e3e..37bb6d43 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -831,7 +831,12 @@ post "/login" do |env| begin validate_response(challenge, token, answer, "sign_in", HMAC_KEY, PG_DB) rescue ex - error_message = ex.message + if ex.message && ex.message == "Invalid user" + error_message = "Invalid CAPTCHA response" + else + error_message = ex.message + end + next templated "error" end diff --git a/src/invidious/users.cr b/src/invidious/users.cr index d46029aa..c8769090 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -251,7 +251,7 @@ def validate_response(challenge, token, user_id, operation, key, db) end if challenge_user_id != user_id - raise "Invalid token" + raise "Invalid user" end if expire < Time.now.to_unix