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
This commit is contained in:
juancarlos.cavero 2026-07-16 19:24:47 +02:00
parent 1f7ec835db
commit 8ce4d3c5d9
3 changed files with 12 additions and 1 deletions

View file

@ -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(

View file

@ -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.');
}

View file

@ -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);