copy of #561 ensure callbackUrl exists when submitting login form (#609)

This commit is contained in:
Peer_Rich 2021-09-12 09:51:59 +01:00 committed by GitHub
parent 2574006f07
commit e48318a34b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,8 +2,16 @@ import { HeadSeo } from "@components/seo/head-seo";
import Link from "next/link"; import Link from "next/link";
import { getCsrfToken } from "next-auth/client"; import { getCsrfToken } from "next-auth/client";
import { getSession } from "@lib/auth"; import { getSession } from "@lib/auth";
import { useEffect } from "react";
import { useRouter } from "next/router";
export default function Login({ csrfToken }) { export default function Login({ csrfToken }) {
const router = useRouter();
useEffect(() => {
if (!router.query?.callbackUrl) {
window.history.replaceState(null, document.title, "?callbackUrl=/");
}
}, [router.query]);
return ( return (
<div className="min-h-screen bg-neutral-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8"> <div className="min-h-screen bg-neutral-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8">
<HeadSeo title="Login" description="Login" /> <HeadSeo title="Login" description="Login" />