forked from administration/panel
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import { signIn, signOut, useSession } from "next-auth/react";
|
|
import Link from "next/link";
|
|
|
|
export function LoginButton() {
|
|
const { data: session } = useSession();
|
|
const params = new URLSearchParams(document.location.search);
|
|
|
|
if (session) {
|
|
return (
|
|
<>
|
|
<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/aYON6GqiqpwSpiZmAbJoOtw8tM2uYsEU.webp`}
|
|
height={320}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Button
|
|
variant="outline"
|
|
onClick={() =>
|
|
signIn("authentik", {
|
|
callbackUrl: params.get("callbackUrl") ?? undefined,
|
|
})
|
|
}
|
|
>
|
|
login with revolt sso
|
|
</Button>
|
|
<img
|
|
src={`https://api.gifbox.me/file/posts/w7iUJfiyKA_zGkHN7Rr625WpaTHYgm4v.webp`}
|
|
height={320}
|
|
/>
|
|
</>
|
|
);
|
|
}
|