fix(demo): graceful UX when YouTube actions are unavailable

The shared demo account no longer hits YouTube affordances: the onboarding
wizard never opens (or renders) for it, the empty-feed prompt nudges into
the shared library instead of the connect wizard, and the browser-facing
/auth/upgrade redirects the demo home instead of returning a raw 403 JSON.
This commit is contained in:
npeter83 2026-06-16 09:27:34 +02:00
parent 5b6d898d31
commit 484c6364e6
6 changed files with 50 additions and 18 deletions

View file

@ -320,13 +320,17 @@ def require_human(user: User = Depends(current_user)) -> User:
@router.get("/upgrade")
async def upgrade(
request: Request, access: str = "read", user: User = Depends(require_human)
request: Request, access: str = "read", user: User = Depends(current_user)
):
"""Incremental consent for the onboarding wizard. `access=read` grants YouTube
read-only (enough to build the feed); `access=write` additionally grants management
(unsubscribe). The shared callback stores whatever Google returns, so `can_read` /
`can_write` flip on once granted. Anything other than an explicit `write` defaults to
the least-privileged read scope."""
# This is the browser-facing redirect entry point, so the shared demo account is bounced
# straight home (no YouTube link is ever attached to it) rather than shown a raw 403.
if user.is_demo:
return RedirectResponse(url="/")
scope = WRITE_SCOPES if access == "write" else READ_SCOPES
return await oauth.google.authorize_redirect(
request,