From 478adcabcadaeaa4a37da9c10bb0489e7a1d091d Mon Sep 17 00:00:00 2001 From: Rajpreet0 Date: Sun, 27 Sep 2026 01:36:02 +0200 Subject: [PATCH 1/2] added authentication with proxy --- app/admin/dashboard/page.tsx | 13 + app/client/dashboard/page.tsx | 8 + app/globals.css | 2 +- app/page.tsx | 7 +- components/ui/field.tsx | 238 ++++++++++++++++++ components/ui/label.tsx | 19 ++ components/ui/separator.tsx | 24 ++ lib/supabase/admin.ts | 8 + lib/supabase/dal.ts | 43 ++++ .../20260927100000_create_profiles_table.sql | 14 ++ ...00100_create_profile_on_signup_trigger.sql | 17 ++ lib/supabase/proxy.ts | 37 +++ lib/supabase/server.ts | 34 ++- modules/loginPage/actions/auth.ts | 54 ++++ modules/loginPage/ui/views/login-view.tsx | 76 ++++++ package-lock.json | 3 +- package.json | 3 +- proxy.ts | 24 ++ 18 files changed, 609 insertions(+), 15 deletions(-) create mode 100644 app/admin/dashboard/page.tsx create mode 100644 app/client/dashboard/page.tsx create mode 100644 components/ui/field.tsx create mode 100644 components/ui/label.tsx create mode 100644 components/ui/separator.tsx create mode 100644 lib/supabase/admin.ts create mode 100644 lib/supabase/dal.ts create mode 100644 lib/supabase/migrations/20260927100000_create_profiles_table.sql create mode 100644 lib/supabase/migrations/20260927100100_create_profile_on_signup_trigger.sql create mode 100644 lib/supabase/proxy.ts create mode 100644 modules/loginPage/actions/auth.ts create mode 100644 modules/loginPage/ui/views/login-view.tsx create mode 100644 proxy.ts diff --git a/app/admin/dashboard/page.tsx b/app/admin/dashboard/page.tsx new file mode 100644 index 0000000..78c41ab --- /dev/null +++ b/app/admin/dashboard/page.tsx @@ -0,0 +1,13 @@ +import { verifySession } from "@/lib/supabase/dal" +import { redirect } from "next/navigation"; + +const AdminDashboard = async () => { + const { isAdmin } = await verifySession(); + if (!isAdmin) redirect("/client/dashboard"); + + return ( +
AdminDashboard
+ ) +} + +export default AdminDashboard \ No newline at end of file diff --git a/app/client/dashboard/page.tsx b/app/client/dashboard/page.tsx new file mode 100644 index 0000000..ec7110a --- /dev/null +++ b/app/client/dashboard/page.tsx @@ -0,0 +1,8 @@ + +const ClientDashboard = () => { + return ( +
page
+ ) +} + +export default ClientDashboard \ No newline at end of file diff --git a/app/globals.css b/app/globals.css index 02d9249..f278a06 100644 --- a/app/globals.css +++ b/app/globals.css @@ -115,7 +115,7 @@ } :root { - --background: var(--ink-0); + --background: oklch(0.99 0 0); --foreground: var(--ink-950); --card: var(--ink-0); --card-foreground: var(--ink-950); diff --git a/app/page.tsx b/app/page.tsx index 527ab30..5dc0188 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,8 +1,5 @@ +import LoginPageView from "@/modules/loginPage/ui/views/login-view"; export default function Home() { - return ( -
- -
- ); + return ; } diff --git a/components/ui/field.tsx b/components/ui/field.tsx new file mode 100644 index 0000000..8ae7f29 --- /dev/null +++ b/components/ui/field.tsx @@ -0,0 +1,238 @@ +"use client" + +import { useMemo } from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "cn" + +import { Label } from "@/components/ui/label" +import { Separator } from "@/components/ui/separator" + +function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) { + return ( +
[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", + className + )} + {...props} + /> + ) +} + +function FieldLegend({ + className, + variant = "legend", + ...props +}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) { + return ( + + ) +} + +function FieldGroup({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +const fieldVariants = cva( + "group/field flex w-full gap-2 data-[invalid=true]:text-destructive", + { + variants: { + orientation: { + vertical: "flex-col *:w-full [&>.sr-only]:w-auto", + horizontal: + "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px", + responsive: + "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px", + }, + }, + defaultVariants: { + orientation: "vertical", + }, + } +) + +function Field({ + className, + orientation = "vertical", + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ) +} + +function FieldContent({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function FieldLabel({ + className, + ...props +}: React.ComponentProps) { + return ( +