Fix 500 callback YouTube: pagina token senza layout admin.

Il layout admin richiedeva admin_logged_in? non disponibile nel callback OAuth.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-02 21:02:51 +02:00
parent cd8e97243f
commit d051d60415
2 changed files with 41 additions and 15 deletions

View File

@@ -1,7 +1,5 @@
# Callback OAuth YouTube (HTML). Non usare Api::V1 — ActionController::API non renderizza le view. # Callback OAuth YouTube (HTML). Non usare Api::V1 — ActionController::API non renderizza le view.
class YoutubeOauthCallbackController < ActionController::Base class YoutubeOauthCallbackController < ActionController::Base
layout "admin"
def show def show
return redirect_to_oauth_error("Codice OAuth mancante") if params[:code].blank? return redirect_to_oauth_error("Codice OAuth mancante") if params[:code].blank?
@@ -11,7 +9,7 @@ class YoutubeOauthCallbackController < ActionController::Base
if ctx[:kind] == :platform if ctx[:kind] == :platform
@refresh_token = tokens[:refresh_token] @refresh_token = tokens[:refresh_token]
@channel_title = tokens[:channel_title] @channel_title = tokens[:channel_title]
return render "admin/youtube/platform_token" return render "admin/youtube/platform_token", layout: false
end end
user = User.find(ctx[:user_id]) user = User.find(ctx[:user_id])

View File

@@ -1,15 +1,43 @@
<h1>Token canale Match Live TV</h1> <!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<title>Token YouTube — Match Live TV</title>
<style>
body { font-family: system-ui, sans-serif; background: #0a0a0e; color: #f0f0f5; margin: 0; padding: 32px 20px; line-height: 1.5; }
.wrap { max-width: 720px; margin: 0 auto; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
pre { background: #111; color: #eee; padding: 12px; overflow: auto; border-radius: 8px; word-break: break-all; }
.muted { color: #999; }
a { color: #ff6b6b; }
.ok { color: #81c784; font-weight: 600; }
</style>
</head>
<body>
<div class="wrap">
<h1>Token canale Match Live TV</h1>
<% if @channel_title.present? %> <% if @channel_title.present? %>
<p>Canale: <strong><%= @channel_title %></strong></p> <p>Canale: <strong><%= @channel_title %></strong></p>
<% end %> <% end %>
<% if @refresh_token.present? %> <% if @refresh_token.present? %>
<p>Aggiungi in <code>/opt/matchlivetv/infra/.env</code> (o locale <code>infra/.env</code>):</p> <p class="ok">Collegamento riuscito. Copia subito questa riga:</p>
<pre style="background:#111;color:#eee;padding:12px;overflow:auto">YOUTUBE_PLATFORM_REFRESH_TOKEN=<%= @refresh_token %></pre> <p>Aggiungi in <code>/opt/matchlivetv/infra/.env</code>:</p>
<p class="muted">Copia ora: non verrà mostrato di nuovo. Poi riavvia il container Rails.</p> <pre id="yt-token">YOUTUBE_PLATFORM_REFRESH_TOKEN=<%= @refresh_token %></pre>
<% else %> <p class="muted">Non verrà mostrato di nuovo. Poi: <code>docker compose -f docker-compose.prod.yml restart rails sidekiq</code></p>
<p class="muted">Google non ha restituito un refresh token. Ripeti il collegamento con <code>prompt=consent</code> (revoca laccesso precedente in Google Account).</p> <% else %>
<% end %> <p class="muted">
Google non ha restituito un refresh token. In
<a href="https://myaccount.google.com/permissions" target="_blank" rel="noopener">account Google → accesso app</a>
revoca «Match Live TV», poi ripeti da
<a href="/admin/youtube/platform">/admin/youtube/platform</a>.
</p>
<% end %>
<p><%= link_to "← Dashboard admin", admin_root_path %></p> <p><a href="/admin/">← Dashboard admin</a></p>
</div>
</body>
</html>