From 47ef5dfe4ca5c103da2c58c61ec6f7e759e7e64f Mon Sep 17 00:00:00 2001 From: Fijxu Date: Sat, 16 Nov 2024 12:27:10 -0300 Subject: [PATCH] Overwirte CONFIG.po_token and CONFIG.visitor_data by the tokens stored on redis This approach is better to prevent conflicts with the upstream repository. --- src/invidious/helpers/redis_tokens.cr | 12 +++++++++--- src/invidious/views/user/tokens.ecr | 15 --------------- 2 files changed, 9 insertions(+), 18 deletions(-) delete mode 100644 src/invidious/views/user/tokens.ecr diff --git a/src/invidious/helpers/redis_tokens.cr b/src/invidious/helpers/redis_tokens.cr index a6b6196c..b79dab51 100644 --- a/src/invidious/helpers/redis_tokens.cr +++ b/src/invidious/helpers/redis_tokens.cr @@ -7,13 +7,19 @@ module Tokens @@po_token = REDIS_DB.get("invidious:po_token") @@visitor_data = REDIS_DB.get("invidious:visitor_data") if !@@po_token.nil? && !@@visitor_data.nil? - LOGGER.debug("RefreshTokens: Successfully updated tokens") + set_tokens + LOGGER.debug("RefreshTokens: Successfully updated po_token and visitor_data") else LOGGER.warn("RefreshTokens: Tokens are empty!") end LOGGER.trace("RefreshTokens: Tokens are:") - LOGGER.trace("RefreshTokens: po_token: #{@@po_token}") - LOGGER.trace("RefreshTokens: visitor_data: #{@@visitor_data}") + LOGGER.trace("RefreshTokens: po_token: #{CONFIG.po_token}") + LOGGER.trace("RefreshTokens: visitor_data: #{CONFIG.visitor_data}") + end + + def set_tokens + CONFIG.po_token = @@po_token + CONFIG.visitor_data = @@visitor_data end def get_tokens diff --git a/src/invidious/views/user/tokens.ecr b/src/invidious/views/user/tokens.ecr deleted file mode 100644 index 768a1968..00000000 --- a/src/invidious/views/user/tokens.ecr +++ /dev/null @@ -1,15 +0,0 @@ -<% content_for "header" do %> -<%= translate(locale, "Invidious token generator") %> - Invidious -<% end %> - -
-
-
-
-

po_token and visitor_data successfully generated!

-

po_token: <%= po_token %>

-

visitor_data: <%= visitor_data %>

-
-
-
-