forked from administration/panel
51 lines
1.1 KiB
TypeScript
51 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 callbackUrl =
|
|
typeof window === "undefined"
|
|
? undefined
|
|
: new URLSearchParams(document.location.search).get("callbackUrl") ??
|
|
undefined;
|
|
|
|
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`}
|
|
className="h-[320px]"
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Button
|
|
variant="outline"
|
|
onClick={() =>
|
|
signIn("authentik", {
|
|
callbackUrl,
|
|
})
|
|
}
|
|
>
|
|
login with revolt sso
|
|
</Button>
|
|
<img
|
|
src={`https://api.gifbox.me/file/posts/w7iUJfiyKA_zGkHN7Rr625WpaTHYgm4v.webp`}
|
|
className="h-[320px]"
|
|
/>
|
|
</>
|
|
);
|
|
}
|