forked from administration/panel
feat: add auth middleware and logout button
parent
72b7e39937
commit
0a3782946e
|
@ -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}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export { default } from "next-auth/middleware";
|
||||
|
||||
export const config = { matcher: ["/panel"] };
|
Loading…
Reference in New Issue