From dbd96c77e457ae17f55490315ffab325d2560e55 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 29 Oct 2024 18:21:58 +0100 Subject: [PATCH] Routes: Simplify actions in token_ajax --- assets/js/handlers.js | 2 +- src/invidious/routes/account.cr | 14 +++----------- src/invidious/views/user/token_manager.ecr | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/assets/js/handlers.js b/assets/js/handlers.js index a3199fa7..67cd9081 100644 --- a/assets/js/handlers.js +++ b/assets/js/handlers.js @@ -91,7 +91,7 @@ var count = document.getElementById('count'); count.textContent--; - var url = '/token_ajax?action_revoke_token=1&redirect=false' + + var url = '/token_ajax?action=revoke_token&redirect=false' + '&referer=' + encodeURIComponent(location.href) + '&session=' + target.getAttribute('data-session'); diff --git a/src/invidious/routes/account.cr b/src/invidious/routes/account.cr index dd65e7a6..c8db207c 100644 --- a/src/invidious/routes/account.cr +++ b/src/invidious/routes/account.cr @@ -328,17 +328,9 @@ module Invidious::Routes::Account end end - if env.params.query["action_revoke_token"]? - action = "action_revoke_token" - else - return env.redirect referer - end - - session = env.params.query["session"]? - session ||= "" - - case action - when .starts_with? "action_revoke_token" + case action = env.params.query["action"]? + when "revoke_token" + session = env.params.query["session"] Invidious::Database::SessionIDs.delete(sid: session, email: user.email) else return error_json(400, "Unsupported action #{action}") diff --git a/src/invidious/views/user/token_manager.ecr b/src/invidious/views/user/token_manager.ecr index a73fa048..8431deb0 100644 --- a/src/invidious/views/user/token_manager.ecr +++ b/src/invidious/views/user/token_manager.ecr @@ -29,7 +29,7 @@

-
" method="post"> + " method="post"> "> ">