-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from bercivarga/feature/auth
Add auth with Clerk
- Loading branch information
Showing
13 changed files
with
674 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Link from "next/link"; | ||
|
||
export default function AuthLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return ( | ||
<div> | ||
<nav className="absolute left-0 top-0 w-full p-6 text-center text-white"> | ||
<Link href="/"> | ||
<span className="text-2xl font-bold">Home</span> | ||
</Link> | ||
</nav> | ||
<main className="flex min-h-screen items-center justify-center bg-slate-900"> | ||
{children} | ||
</main> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SignIn } from "@clerk/nextjs"; | ||
|
||
export default function SignInPage() { | ||
return <SignIn redirectUrl={"/dashboard"} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SignUp } from "@clerk/nextjs"; | ||
|
||
export default function SignUpPage() { | ||
return <SignUp />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function MarketingLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return <>{children}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { auth } from "@clerk/nextjs"; | ||
import { Metadata } from "next"; | ||
import Link from "next/link"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
|
||
export const metadata: Metadata = { | ||
title: "CF Showcase Project", | ||
description: "Made for CLEVER°FRANKE by @berci.dev", | ||
}; | ||
|
||
export default function Home() { | ||
const { userId } = auth(); | ||
|
||
return ( | ||
<main className="flex min-h-screen items-center justify-center"> | ||
<div className="flex flex-col gap-4 p-6 md:items-center md:text-center"> | ||
<h2> | ||
Welcome to the | ||
<br /> CF Showcase | ||
</h2> | ||
<p>Sign in or sign up in order to explore the app.</p> | ||
<div className="flex gap-2"> | ||
{userId ? ( | ||
<Link href="/dashboard"> | ||
<Button>To dashboard</Button> | ||
</Link> | ||
) : ( | ||
<> | ||
<Link href="/sign-in"> | ||
<Button>Sign in</Button> | ||
</Link> | ||
<Link href="/sign-up"> | ||
<Button variant="outline">Sign up</Button> | ||
</Link> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { UserButton } from "@clerk/nextjs"; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return ( | ||
<div className="flex h-screen"> | ||
<aside className="flex h-full w-64 flex-col justify-between bg-indigo-100 p-6"> | ||
<div> | ||
<span>TODO: Add sidebar menu</span> | ||
</div> | ||
<div> | ||
<UserButton afterSignOutUrl="/" /> | ||
</div> | ||
</aside> | ||
{children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Dashboard", | ||
description: "Start working on your ideas here.", | ||
}; | ||
|
||
export default function Home() { | ||
return ( | ||
<main> | ||
<h1>Dashboard</h1> | ||
<p>hi</p> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { authMiddleware } from "@clerk/nextjs"; | ||
|
||
export default authMiddleware({ | ||
// Routes that can be accessed while signed out | ||
publicRoutes: [ | ||
/^(?!\/dashboard).*/, // Match routes that don't start with "/dashboard" | ||
], | ||
// Routes that can always be accessed, and have | ||
// no authentication information | ||
// ignoredRoutes: ["/no-auth-in-this-route"], | ||
}); | ||
|
||
export const config = { | ||
// Protects all routes, including api/trpc. | ||
// See https://clerk.com/docs/references/nextjs/auth-middleware | ||
// for more information about configuring your Middleware | ||
matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"], | ||
}; |
Oops, something went wrong.