diff --git a/apps/next/app/(authenticated)/guest/layout.tsx b/apps/next/app/(authenticated)/guest/layout.tsx deleted file mode 100644 index a728084..0000000 --- a/apps/next/app/(authenticated)/guest/layout.tsx +++ /dev/null @@ -1,13 +0,0 @@ -export default function Layout({ children }: { children: React.ReactNode }) { - return ( -
-
-

- Guest page -

-

This is page accessible to guest accounts

-
-
{children}
-
- ) -} diff --git a/apps/next/app/(authenticated)/guest/page.tsx b/apps/next/app/(authenticated)/guest/page.tsx deleted file mode 100644 index b74cc3d..0000000 --- a/apps/next/app/(authenticated)/guest/page.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { redirect } from "next/navigation" - -import { GuestForm } from "@/components/user/guest-form" - -import { createClient } from "@/modules/utils/server" -import { isAnonymousUser } from "@/modules/user/helpers" - -export default async function Page() { - const supabase = createClient() - - const { - data: { user }, - } = await supabase.auth.getUser() - - if (!user || !isAnonymousUser(user)) { - redirect("/login") - } - - return -} diff --git a/apps/next/app/(authenticated)/bookmarks/layout.tsx b/apps/next/app/bookmarks/layout.tsx similarity index 100% rename from apps/next/app/(authenticated)/bookmarks/layout.tsx rename to apps/next/app/bookmarks/layout.tsx diff --git a/apps/next/app/(authenticated)/bookmarks/page.tsx b/apps/next/app/bookmarks/page.tsx similarity index 100% rename from apps/next/app/(authenticated)/bookmarks/page.tsx rename to apps/next/app/bookmarks/page.tsx diff --git a/apps/next/app/layout.tsx b/apps/next/app/layout.tsx index 2d1a782..5d1ec35 100644 --- a/apps/next/app/layout.tsx +++ b/apps/next/app/layout.tsx @@ -9,6 +9,8 @@ import "./globals.css" import type { Viewport } from "next" +import Navigation from "./navigation" + const fontSans = FontSans({ subsets: ["latin"], variable: "--font-sans", @@ -27,7 +29,9 @@ export default function RootLayout({ fontSans.variable )} > - {children} + + {children} + ) diff --git a/apps/next/app/login/new/page.tsx b/apps/next/app/login/new/page.tsx index d642c98..05dc54a 100644 --- a/apps/next/app/login/new/page.tsx +++ b/apps/next/app/login/new/page.tsx @@ -12,7 +12,7 @@ export default async function Page() { } = await supabase.auth.getUser() if (user) { - user.is_anonymous ? redirect("/guest") : redirect("/settings/accounts") + redirect("/settings/accounts") } return diff --git a/apps/next/app/login/new/passwordless/page.tsx b/apps/next/app/login/new/passwordless/page.tsx index c48a957..1c5c96b 100644 --- a/apps/next/app/login/new/passwordless/page.tsx +++ b/apps/next/app/login/new/passwordless/page.tsx @@ -12,7 +12,7 @@ export default async function Page() { } = await supabase.auth.getUser() if (user) { - user.is_anonymous ? redirect("/guest") : redirect("/settings/accounts") + redirect("/settings") } return diff --git a/apps/next/app/login/otp/confirm/page.tsx b/apps/next/app/login/otp/confirm/page.tsx index a49261d..c18b3ea 100644 --- a/apps/next/app/login/otp/confirm/page.tsx +++ b/apps/next/app/login/otp/confirm/page.tsx @@ -21,7 +21,7 @@ export default async function Page({ } = await supabase.auth.getUser() if (user) { - redirect("/settings/accounts") + redirect("/settings") } if (!searchParams.email) { diff --git a/apps/next/app/login/otp/page.tsx b/apps/next/app/login/otp/page.tsx index 2ec9ca4..3cb78e8 100644 --- a/apps/next/app/login/otp/page.tsx +++ b/apps/next/app/login/otp/page.tsx @@ -12,7 +12,7 @@ export default async function Page() { } = await supabase.auth.getUser() if (user) { - redirect("/settings/accounts") + redirect("/settings") } return diff --git a/apps/next/app/login/page.tsx b/apps/next/app/login/page.tsx index 2b1b463..d9b66d1 100644 --- a/apps/next/app/login/page.tsx +++ b/apps/next/app/login/page.tsx @@ -4,7 +4,6 @@ import { z } from "zod" import { LoginForm } from "@/components/user/login/login-form" import { createClient } from "@/modules/utils/server" -import { isAnonymousUser } from "@/modules/user/helpers" export default async function Page({ searchParams: { error }, @@ -18,7 +17,7 @@ export default async function Page({ } = await supabase.auth.getUser() if (user) { - isAnonymousUser(user) ? redirect("/guest") : redirect("/settings/accounts") + redirect("/settings") } if (error) { diff --git a/apps/next/app/login/reset/page.tsx b/apps/next/app/login/reset/page.tsx index 3f915e2..adc6913 100644 --- a/apps/next/app/login/reset/page.tsx +++ b/apps/next/app/login/reset/page.tsx @@ -12,7 +12,7 @@ export default async function Page() { } = await supabase.auth.getUser() if (user) { - redirect("/settings/accounts") + redirect("/settings") } return diff --git a/apps/next/app/(authenticated)/layout.tsx b/apps/next/app/navigation.tsx similarity index 62% rename from apps/next/app/(authenticated)/layout.tsx rename to apps/next/app/navigation.tsx index 6d743fc..817ec1e 100644 --- a/apps/next/app/(authenticated)/layout.tsx +++ b/apps/next/app/navigation.tsx @@ -1,9 +1,8 @@ import { ApplicationLayout } from "@/components/application-layout" import { createClient } from "@/modules/utils/server" -import { isAnonymousUser } from "@/modules/user/helpers" -export default async function Layout({ +export default async function Navigation({ children, }: { children: React.ReactNode @@ -14,11 +13,12 @@ export default async function Layout({ data: { user }, } = await supabase.auth.getUser() + if (!user) { + return <>{children} + } + return ( - + {children} ) diff --git a/apps/next/app/page.tsx b/apps/next/app/page.tsx index 516cefc..552b076 100644 --- a/apps/next/app/page.tsx +++ b/apps/next/app/page.tsx @@ -1,7 +1,6 @@ import { redirect } from "next/navigation" import { createClient } from "@/modules/utils/server" -import { isAnonymousUser } from "@/modules/user/helpers" export default async function Home() { const supabase = createClient() @@ -11,7 +10,7 @@ export default async function Home() { } = await supabase.auth.getUser() if (user) { - isAnonymousUser(user) ? redirect("/guest") : redirect("/settings/accounts") + redirect("/settings") } redirect("/login") diff --git a/apps/next/app/(authenticated)/settings/accounts/page.tsx b/apps/next/app/settings/accounts/page.tsx similarity index 72% rename from apps/next/app/(authenticated)/settings/accounts/page.tsx rename to apps/next/app/settings/accounts/page.tsx index 4f0ab31..c9ad024 100644 --- a/apps/next/app/(authenticated)/settings/accounts/page.tsx +++ b/apps/next/app/settings/accounts/page.tsx @@ -1,6 +1,6 @@ import { redirect } from "next/navigation" -import { Accounts } from "@/components/user/accounts" +import { Accounts } from "@/components/user/settings/accounts" import { createClient } from "@/modules/utils/server" @@ -15,5 +15,9 @@ export default async function Page() { redirect("/login") } + if (user.is_anonymous) { + redirect("/settings") + } + return } diff --git a/apps/next/app/(authenticated)/settings/credentials/page.tsx b/apps/next/app/settings/credentials/page.tsx similarity index 66% rename from apps/next/app/(authenticated)/settings/credentials/page.tsx rename to apps/next/app/settings/credentials/page.tsx index f2d01e6..b53e0e5 100644 --- a/apps/next/app/(authenticated)/settings/credentials/page.tsx +++ b/apps/next/app/settings/credentials/page.tsx @@ -1,6 +1,6 @@ import { redirect } from "next/navigation" -import { CredentialsForm } from "@/components/user/credentials-form" +import { CredentialsForm } from "@/components/user/settings/credentials-form" import { createClient } from "@/modules/utils/server" @@ -11,9 +11,13 @@ export default async function Page() { data: { user }, } = await supabase.auth.getUser() - if (!user?.email) { + if (!user) { redirect("/login") } + if (user.is_anonymous || !user.email) { + redirect("/settings") + } + return } diff --git a/apps/next/app/(authenticated)/settings/layout.tsx b/apps/next/app/settings/layout.tsx similarity index 61% rename from apps/next/app/(authenticated)/settings/layout.tsx rename to apps/next/app/settings/layout.tsx index ba48cde..f1406df 100644 --- a/apps/next/app/(authenticated)/settings/layout.tsx +++ b/apps/next/app/settings/layout.tsx @@ -1,17 +1,36 @@ import { DynamicNavigationLinks } from "@/components/dynamic-navigation-links" -export default function Layout({ children }: { children: React.ReactNode }) { +import { createClient } from "@/modules/utils/server" + +export default async function Layout({ + children, +}: { + children: React.ReactNode +}) { + const supabase = createClient() + + const { + data: { user }, + } = await supabase.auth.getUser() + + if (!user) return null + return (

- Settings + {!user.is_anonymous ? "Settings" : "Guest Settings"}

-

Manage your accounts, profile and credentials settings

+

+ {!user.is_anonymous + ? "Manage your accounts, profile and credentials settings" + : "Access to settings is restricted to anonymous users"} +