forked from administration/panel
feat: add auth middleware and logout button
parent
72b7e39937
commit
0a3782946e
|
@ -1,20 +1,23 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
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";
|
import Link from "next/link";
|
||||||
|
|
||||||
export function LoginButton() {
|
export function LoginButton() {
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
if (session || true) {
|
if (session) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Link href={"/panel"}>
|
<Link href="/panel">
|
||||||
<Button variant="outline">continue</Button>
|
<Button variant="outline">continue</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Button variant="destructive" onClick={() => signOut()}>
|
||||||
|
log out
|
||||||
|
</Button>
|
||||||
<img
|
<img
|
||||||
src={`https://api.gifbox.me/file/posts/QF8HezSH-AtTM9hT4pKISu-foBzdRC4e.webp`}
|
src={`https://api.gifbox.me/file/posts/aYON6GqiqpwSpiZmAbJoOtw8tM2uYsEU.webp`}
|
||||||
height={320}
|
height={320}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
@ -23,9 +26,9 @@ export function LoginButton() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Link href={"/panel"}>
|
<Button variant="outline" onClick={() => signIn()}>
|
||||||
<Button variant="outline">login with revolt sso</Button>
|
login with revolt sso
|
||||||
</Link>
|
</Button>
|
||||||
<img
|
<img
|
||||||
src={`https://api.gifbox.me/file/posts/w7iUJfiyKA_zGkHN7Rr625WpaTHYgm4v.webp`}
|
src={`https://api.gifbox.me/file/posts/w7iUJfiyKA_zGkHN7Rr625WpaTHYgm4v.webp`}
|
||||||
height={320}
|
height={320}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export { default } from "next-auth/middleware";
|
||||||
|
|
||||||
|
export const config = { matcher: ["/panel"] };
|
Loading…
Reference in New Issue