From 82d75da0a706de97dc0bbc5fbbfdb8d3068cf862 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:53:28 +0000 Subject: [PATCH] feat: update AppNoPageAccess to show Login for unauthenticated users and embed pages - Add authentication state detection using useSupabaseContext - Detect embed page context using window.location.pathname - Show 'Login' button with redirect parameter for unauthenticated users or embed pages - Keep 'Go home' button for authenticated users without asset access - Include current URL as redirect parameter in login link Co-Authored-By: nate@buster.so --- apps/web/src/controllers/AppNoPageAccess.tsx | 43 ++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/apps/web/src/controllers/AppNoPageAccess.tsx b/apps/web/src/controllers/AppNoPageAccess.tsx index eb99d0ef9..789095106 100644 --- a/apps/web/src/controllers/AppNoPageAccess.tsx +++ b/apps/web/src/controllers/AppNoPageAccess.tsx @@ -1,29 +1,58 @@ +'use client'; + import Link from 'next/link'; -import React from 'react'; +import React, { useMemo } from 'react'; import { BusterLogo } from '@/assets/svg/BusterLogo'; import { Button } from '@/components/ui/buttons'; import { Title } from '@/components/ui/typography'; +import { useSupabaseContext } from '@/context/Supabase'; import { BusterRoutes, createBusterRoute } from '@/routes'; export const AppNoPageAccess: React.FC<{ assetId: string; }> = React.memo(({ assetId }) => { + const isAnonymousUser = useSupabaseContext((x) => x.isAnonymousUser); + + const { buttonText, linkUrl } = useMemo(() => { + const isEmbedPage = typeof window !== 'undefined' && window.location.pathname.startsWith('/embed'); + + const shouldShowLogin = isAnonymousUser || isEmbedPage; + + if (shouldShowLogin) { + const currentUrl = typeof window !== 'undefined' + ? `${window.location.pathname}${window.location.search}` + : ''; + + return { + buttonText: 'Login', + linkUrl: createBusterRoute({ + route: BusterRoutes.AUTH_LOGIN, + next: encodeURIComponent(currentUrl) + }) + }; + } + + return { + buttonText: 'Go home', + linkUrl: createBusterRoute({ + route: BusterRoutes.APP_HOME + }) + }; + }, [isAnonymousUser]); + return (
- {'It looks like you don’t have access to this file...'} + {"It looks like you don't have access to this file..."}
- - + +