link-stack/apps/leafcutter/lib/checkAuth.ts
2023-02-13 13:46:56 +00:00

21 lines
430 B
TypeScript

import { GetServerSideProps, GetServerSidePropsContext } from "next";
import { getSession } from "next-auth/react";
export const checkAuth: GetServerSideProps = async (
context: GetServerSidePropsContext
) => {
const session = await getSession(context);
if (!session) {
return {
redirect: {
destination: "/login",
permanent: false,
},
};
}
return {
props: { session },
};
};