-
-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add login page and logout button
- Loading branch information
1 parent
400b696
commit c883bee
Showing
9 changed files
with
111 additions
and
59 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
35 changes: 35 additions & 0 deletions
35
packages/web/app/dashboard/components/SidebarProfileOptions.tsx
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,35 @@ | ||
"use client"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
import { LogOut, MoreHorizontal } from "lucide-react"; | ||
import { signOut } from "next-auth/react"; | ||
|
||
export default function SidebarProfileOptions() { | ||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost"> | ||
<MoreHorizontal /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-fit"> | ||
<DropdownMenuItem | ||
onClick={() => | ||
signOut({ | ||
callbackUrl: "/", | ||
}) | ||
} | ||
> | ||
<LogOut className="mr-2 size-4" /> | ||
<span>Sign Out</span> | ||
</DropdownMenuItem> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
import { LoginButton } from "@/components/auth/login"; | ||
import { LogoutButton } from "@/components/auth/logout"; | ||
import Link from "next/link"; | ||
import { getServerAuthSession } from "@/server/auth"; | ||
import { redirect } from "next/navigation"; | ||
|
||
export default function Home() { | ||
return ( | ||
<main className="flex min-h-screen flex-col items-center justify-between p-24"> | ||
<div> | ||
<LoginButton /> | ||
<br /> | ||
<br /> | ||
<LogoutButton /> | ||
<br /> | ||
<br /> | ||
<Link href="/bookmarks">Bookmarks</Link> | ||
</div> | ||
</main> | ||
); | ||
export default async function Home() { | ||
// TODO: Home currently just redirects between pages until we build a proper landing page | ||
const session = await getServerAuthSession(); | ||
if (!session) { | ||
redirect("/signin"); | ||
} | ||
|
||
redirect("/dashboard/bookmarks"); | ||
} |
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,16 @@ | ||
import { getProviders, signIn } from "next-auth/react"; | ||
import SignInProviderButton from "./SignInProviderButton"; | ||
|
||
export default async function SignInForm() { | ||
const providers = (await getProviders()) ?? []; | ||
|
||
return ( | ||
<div> | ||
{Object.values(providers).map((provider) => ( | ||
<div key={provider.name}> | ||
<SignInProviderButton provider={provider} /> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/web/app/signin/components/SignInProviderButton.tsx
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 @@ | ||
"use client"; | ||
import { Button } from "@/components/ui/button"; | ||
import { ClientSafeProvider, signIn } from "next-auth/react"; | ||
|
||
export default function SignInProviderButton({ | ||
provider, | ||
}: { | ||
provider: ClientSafeProvider; | ||
}) { | ||
return ( | ||
<Button | ||
onClick={() => | ||
signIn(provider.id, { | ||
callbackUrl: "/", | ||
}) | ||
} | ||
> | ||
Sign in with {provider.name} | ||
</Button> | ||
); | ||
} |
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,19 @@ | ||
import { Brain } from "lucide-react"; | ||
import SignInForm from "./components/SignInForm"; | ||
|
||
export default async function SignInPage() { | ||
// TODO Add support for email and credential signin form | ||
return ( | ||
<div className="flex min-h-screen flex-col items-center justify-center"> | ||
<div className="flex space-x-2"> | ||
<span> | ||
<Brain size="30" className="h-full" /> | ||
</span> | ||
<span className="text-4xl">Remember</span> | ||
</div> | ||
<div className="mt-20 flex w-96 flex-col items-center rounded-xl border border-gray-300 p-20"> | ||
<SignInForm /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.