Project setup
This commit is contained in:
parent
6c45dec07b
commit
95a21d6f50
29 changed files with 12083 additions and 77 deletions
21
lib/checkAuth.ts
Normal file
21
lib/checkAuth.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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 },
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue