fix: csrf on more public pages
This commit is contained in:
parent
5b8c41c203
commit
cd2d8bdb31
|
@ -5,6 +5,7 @@ import type { GetServerSidePropsContext } from "next";
|
|||
import { getCsrfToken, signIn } from "next-auth/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { setCsrfToken } from "pages/api/auth/csrf";
|
||||
import type { CSSProperties } from "react";
|
||||
import { useState } from "react";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
|
@ -279,6 +280,7 @@ inferSSRProps<typeof _getServerSideProps> & WithNonceProps<{}>) {
|
|||
|
||||
// TODO: Once we understand how to retrieve prop types automatically from getServerSideProps, remove this temporary variable
|
||||
const _getServerSideProps = async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
setCsrfToken(context.res);
|
||||
const { req, res, query } = context;
|
||||
|
||||
const session = await getServerSession({ req, res });
|
||||
|
|
|
@ -71,6 +71,7 @@ Logout.PageWrapper = PageWrapper;
|
|||
export default Logout;
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
setCsrfToken(context.res);
|
||||
const ssr = await ssrInit(context);
|
||||
// Deleting old cookie manually, remove this code after all existing cookies have expired
|
||||
context.res.setHeader(
|
||||
|
|
|
@ -30,6 +30,7 @@ signin.PageWrapper = PageWrapper;
|
|||
export default signin;
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
setCsrfToken(context.res);
|
||||
const { req, res } = context;
|
||||
|
||||
const session = await getServerSession({ req, res });
|
||||
|
|
Loading…
Reference in New Issue
Block a user