1
0
Fork 0

fix: support SSR for login button

fix-1
Paul Makles 2023-07-30 12:15:29 +01:00
parent 68851f1b17
commit 893ea3d930
No known key found for this signature in database
GPG Key ID: 5059F398521BB0F6
1 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,11 @@ import Link from "next/link";
export function LoginButton() {
const { data: session } = useSession();
const params = new URLSearchParams(document.location.search);
const callbackUrl =
typeof window === "undefined"
? undefined
: new URLSearchParams(document.location.search).get("callbackUrl") ??
undefined;
if (session) {
return (
@ -31,7 +35,7 @@ export function LoginButton() {
variant="outline"
onClick={() =>
signIn("authentik", {
callbackUrl: params.get("callbackUrl") ?? undefined,
callbackUrl,
})
}
>