diff --git a/src/invidious/helpers/redis_tokens.cr b/src/invidious/helpers/redis_tokens.cr index 9650ecf9..a6b6196c 100644 --- a/src/invidious/helpers/redis_tokens.cr +++ b/src/invidious/helpers/redis_tokens.cr @@ -6,11 +6,11 @@ module Tokens def refresh_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") - else - LOGGER.warn("RefreshTokens: Tokens are empty!") - end + if !@@po_token.nil? && !@@visitor_data.nil? + LOGGER.debug("RefreshTokens: Successfully updated tokens") + 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}") @@ -27,28 +27,4 @@ module Tokens def get_visitor_data return @@visitor_data end - - def generate_tokens(user : String) - po_token = "" - visitor_data = "" - attempts = 0 - - LOGGER.debug("Generating po_token and visitor_data for user: '#{user}'") - REDIS_DB.publish("generate-token", "#{user}") - - while REDIS_DB.get("invidious:#{user}:po_token").nil? && REDIS_DB.get("invidious:#{user}:visitor_data").nil? - if attempts > 50 - break - end - LOGGER.debug("Waiting for tokens to arrive at redis for user: '#{user}'") - attempts += 1 - sleep 250.milliseconds - end - - po_token = REDIS_DB.get("invidious:#{user}:po_token") - visitor_data = REDIS_DB.get("invidious:#{user}:visitor_data") - - LOGGER.debug("Tokens successfully generated for user: '#{user}'") - return {po_token, visitor_data} - end end diff --git a/src/invidious/routes/account.cr b/src/invidious/routes/account.cr index 345c96cf..8086a54e 100644 --- a/src/invidious/routes/account.cr +++ b/src/invidious/routes/account.cr @@ -349,40 +349,4 @@ module Invidious::Routes::Account return "{}" end end - - # ------------------- - # poToken and visitorData tokens generation - # ------------------- - - # Generates a poToken & visitorData for the user, server side - def generate_tokens(env) - locale = env.get("preferences").as(Preferences).locale - preferences = env.get("preferences").as(Preferences) - - user = env.get? "user" - sid = env.get? "sid" - referer = get_referer(env) - - if !user - return env.redirect referer - end - - user = user.as(User) - - po_token, visitor_data = Tokens.generate_tokens(user.email) - - if po_token.nil? || visitor_data.nil? - return error_template(500, "Internal server error. Please submit an issue here IF THE ISSUE PERSISTS: https://git.nadeko.net/Fijxu/invidious/issues") - end - - user.preferences.po_token = po_token - user.preferences.visitor_data = visitor_data - - Invidious::Database::Users.update_preferences(user) - - REDIS_DB.del("invidious:#{user.email}:po_token") - REDIS_DB.del("invidious:#{user.email}:visitor_data") - - templated "user/tokens" - end end diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index 8c082cf9..9009062f 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -76,7 +76,6 @@ module Invidious::Routing post "/authorize_token", Routes::Account, :post_authorize_token get "/token_manager", Routes::Account, :token_manager post "/token_ajax", Routes::Account, :token_ajax - get "/generate_tokens", Routes::Account, :generate_tokens post "/subscription_ajax", Routes::Subscriptions, :toggle_subscription get "/subscription_manager", Routes::Subscriptions, :subscription_manager end diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr index fde9f203..9dbe298c 100644 --- a/src/invidious/views/user/preferences.ecr +++ b/src/invidious/views/user/preferences.ecr @@ -126,12 +126,6 @@ checked<% end %>> - <% if env.get?("user") %> -
- <%= translate(locale, "Generate po_token and visitor_data for your account") %> -
- <% end %> - <%= translate(locale, "preferences_category_visual") %>