From 8ce4d3c5d92fb8e73f06348a1372c7a53fce9147 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Thu, 16 Jul 2026 19:24:47 +0200 Subject: [PATCH] feat(social): auto-connect socials after paying, same-tab redirect, hide calendar - social connect JWT: showCalendar=false (hide scheduling calendar in white-label page) - connect opens in the same tab so the page's redirectUrl returns the user to the app - after the first plan activation (checkout success), take the user straight to the social-connect flow; guarded so top-up checkouts don't re-trigger it --- cloud/social_profiles.py | 1 + dashboard/src/App.jsx | 3 ++- dashboard/src/components/AccountPage.jsx | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cloud/social_profiles.py b/cloud/social_profiles.py index e7fe0c9..e472d9f 100644 --- a/cloud/social_profiles.py +++ b/cloud/social_profiles.py @@ -80,6 +80,7 @@ async def get_connect_url(username: str) -> str: "redirectUrl": f"{settings.frontend_url}/#/account?connected=1", "redirectButtonText": "Back to OpenShorts", "platforms": CONNECT_PLATFORMS, + "showCalendar": False, # hide the scheduling calendar in the connect page } async with httpx.AsyncClient(timeout=20) as client: resp = await client.post( diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index 78df909..f3b99f8 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -353,7 +353,8 @@ function App() { const handleConnectSocials = async () => { try { const { access_url } = await apiJson('/api/social/connect', { method: 'POST' }); - if (access_url) window.open(access_url, '_blank', 'noopener'); + // Same tab so the connect page's redirectUrl brings the user back into the app. + if (access_url) window.location.href = access_url; } catch (e) { alert('Could not open the connection page. Please try again.'); } diff --git a/dashboard/src/components/AccountPage.jsx b/dashboard/src/components/AccountPage.jsx index cae7fef..d0fe109 100644 --- a/dashboard/src/components/AccountPage.jsx +++ b/dashboard/src/components/AccountPage.jsx @@ -24,6 +24,15 @@ export default function AccountPage() { if ((data && data.plan) || tries > 15) { clearInterval(t); setActivating(false); + // First time a plan activates, take the user straight to connect their + // socials. Guard with a flag so top-up checkouts don't re-trigger it. + if (data && data.plan && !localStorage.getItem('os_socials_prompted')) { + localStorage.setItem('os_socials_prompted', '1'); + try { + const { access_url } = await apiJson('/api/social/connect', { method: 'POST' }); + if (access_url) { window.location.href = access_url; return; } + } catch (_) { /* fall through to the account page */ } + } window.location.hash = '#/account'; } }, 2000);