1
0
Fork 0

feat: add auth middleware and logout button

fix-1
Paul Makles 2023-07-30 11:43:39 +01:00
parent 72b7e39937
commit 0a3782946e
No known key found for this signature in database
GPG Key ID: 5059F398521BB0F6
2 changed files with 13 additions and 7 deletions

View File

@ -1,20 +1,23 @@
"use client";
import { Button } from "@/components/ui/button";
import { useSession } from "next-auth/react";
import { signIn, signOut, useSession } from "next-auth/react";
import Link from "next/link";
export function LoginButton() {
const { data: session } = useSession();
if (session || true) {
if (session) {
return (
<>
<Link href={"/panel"}>
<Link href="/panel">
<Button variant="outline">continue</Button>
</Link>
<Button variant="destructive" onClick={() => signOut()}>
log out
</Button>
<img
src={`https://api.gifbox.me/file/posts/QF8HezSH-AtTM9hT4pKISu-foBzdRC4e.webp`}
src={`https://api.gifbox.me/file/posts/aYON6GqiqpwSpiZmAbJoOtw8tM2uYsEU.webp`}
height={320}
/>
</>
@ -23,9 +26,9 @@ export function LoginButton() {
return (
<>
<Link href={"/panel"}>
<Button variant="outline">login with revolt sso</Button>
</Link>
<Button variant="outline" onClick={() => signIn()}>
login with revolt sso
</Button>
<img
src={`https://api.gifbox.me/file/posts/w7iUJfiyKA_zGkHN7Rr625WpaTHYgm4v.webp`}
height={320}

3
middleware.js Normal file
View File

@ -0,0 +1,3 @@
export { default } from "next-auth/middleware";
export const config = { matcher: ["/panel"] };