generated from t3-oss/create-t3-turbo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
844 additions
and
85 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
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 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,14 @@ | ||
import { SiteHeader } from "@/components/site-header" | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<> | ||
<SiteHeader /> | ||
{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
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,75 @@ | ||
import type { Metadata } from "next" | ||
import Link from "next/link" | ||
import { redirect } from "next/navigation" | ||
import { SiDiscord, SiGithub } from "@icons-pack/react-simple-icons" | ||
import { CommandIcon } from "lucide-react" | ||
|
||
import { auth, providers } from "@acme/auth" | ||
import { cn } from "@acme/ui" | ||
import { Button } from "@acme/ui/button" | ||
|
||
import { Logo } from "@/components/logo" | ||
|
||
export const metadata: Metadata = { | ||
title: "Auth", | ||
} | ||
|
||
function SigninIcon({ | ||
iconName, | ||
className, | ||
}: { | ||
iconName: string | ||
className?: string | ||
}) { | ||
switch (iconName) { | ||
case "github": | ||
return <SiGithub className={cn("mr-1 h-4 w-4", className)} /> | ||
case "discord": | ||
return <SiDiscord className={cn("mr-1 h-4 w-4", className)} /> | ||
default: | ||
return <CommandIcon className={cn("mr-1 h-4 w-4", className)} /> | ||
} | ||
} | ||
|
||
export default async function AuthPage() { | ||
const session = await auth() | ||
|
||
if (session.user) { | ||
redirect("/") | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="container relative grid h-screen flex-col items-center justify-center lg:max-w-none lg:grid-cols-2 lg:px-0"> | ||
<div className="relative hidden h-full flex-col bg-muted p-10 dark:border-r dark:text-white lg:flex"> | ||
<div className="absolute inset-0 bg-zinc-200 dark:bg-zinc-900" /> | ||
<Logo /> | ||
</div> | ||
|
||
<div className="lg:p-8"> | ||
<div className="mx-auto flex w-[350px] flex-col justify-center space-y-6"> | ||
<div className="flex flex-col space-y-2 text-center"> | ||
<div className="mb-10 flex justify-center lg:hidden"> | ||
<Logo /> | ||
</div> | ||
<h1 className="mb-4 text-2xl font-semibold tracking-tight"> | ||
Sign in with | ||
</h1> | ||
|
||
{Object.entries(providers).map( | ||
([providerKey, provider], index) => ( | ||
<Button variant="outline" type="button" asChild key={index}> | ||
<Link href={`/api/auth/${providerKey}/login`}> | ||
<SigninIcon iconName={providerKey} /> | ||
{provider.name} | ||
</Link> | ||
</Button> | ||
), | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</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 { Spinner } from "../components/spinner" | ||
|
||
export default function Loading() { | ||
return <Spinner /> | ||
} |
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,17 @@ | ||
import { CommandIcon } from "lucide-react" | ||
|
||
import { cn } from "@acme/ui" | ||
|
||
export function Logo({ className }: { className?: string }) { | ||
return ( | ||
<div | ||
className={cn( | ||
"relative flex items-center text-lg font-medium", | ||
className, | ||
)} | ||
> | ||
<CommandIcon className="mr-1" /> | ||
Acme Inc | ||
</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,28 @@ | ||
import Link from "next/link" | ||
|
||
import { ThemeToggle } from "@acme/ui/theme" | ||
|
||
import { Logo } from "@/components/logo" | ||
import { UserMenu } from "@/components/user-menu" | ||
|
||
export function SiteHeader() { | ||
return ( | ||
<header className=" sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60"> | ||
<div className="container"> | ||
<nav | ||
className="mx-auto flex items-center justify-between " | ||
aria-label="Global" | ||
> | ||
<Link href="/" className="-m-1.5 p-1.5"> | ||
<Logo className="h-16" /> | ||
</Link> | ||
|
||
<div className="hidden gap-1 lg:flex"> | ||
<UserMenu /> | ||
<ThemeToggle /> | ||
</div> | ||
</nav> | ||
</div> | ||
</header> | ||
) | ||
} |
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,14 @@ | ||
import { Loader2Icon } from "lucide-react" | ||
|
||
export function Spinner() { | ||
return ( | ||
<div className="container relative grid h-screen flex-col items-center justify-center "> | ||
<div className="mx-auto flex w-[350px] flex-col justify-center space-y-6 "> | ||
<div className="flex items-center space-x-4"> | ||
<Loader2Icon className="animate-spin" /> | ||
Loading... | ||
</div> | ||
</div> | ||
</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,52 @@ | ||
import Link from "next/link" | ||
import { UserIcon } from "lucide-react" | ||
|
||
import { auth } from "@acme/auth" | ||
import { Button } from "@acme/ui/button" | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuGroup, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "@acme/ui/dropdown-menu" | ||
|
||
import { logoutAction } from "@/actions/logout" | ||
|
||
export async function UserMenu() { | ||
const session = await auth() | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="outline" size="icon"> | ||
<UserIcon /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-56" align="end" forceMount> | ||
<DropdownMenuLabel className="font-normal"> | ||
<div className="flex flex-col space-y-1"> | ||
<p className="text-sm font-medium leading-none"> | ||
Hello {session.user?.name} | ||
</p> | ||
</div> | ||
</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuGroup> | ||
<DropdownMenuItem> | ||
<Link href="/users/settings">Settings</Link> | ||
</DropdownMenuItem> | ||
</DropdownMenuGroup> | ||
<DropdownMenuSeparator /> | ||
|
||
<form action={logoutAction}> | ||
<DropdownMenuItem> | ||
<button>Sign out</button> | ||
</DropdownMenuItem> | ||
</form> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
) | ||
} |
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 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 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 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
Oops, something went wrong.