Add basic index, complete login route with validation

This commit is contained in:
Xevion
2023-02-27 18:11:58 -06:00
parent 0ec3dee644
commit e07bd4c1f7
4 changed files with 92 additions and 0 deletions

31
src/pages/index.tsx Normal file
View File

@@ -0,0 +1,31 @@
import {GetServerSidePropsContext, GetServerSidePropsResult, NextPage} from "next";
import {z} from "zod";
import {env} from "@/env/server.mjs";
type Props = {
authenticated: boolean;
}
export async function getServerSideProps({query}: GetServerSidePropsContext): Promise<GetServerSidePropsResult<Props>> {
const parsedKey = z.string().safeParse(query?.key);
if (parsedKey.success && env.API_KEY === parsedKey.data)
return {
props: {
authenticated: true
}
}
return {
redirect: {
destination: '/login',
permanent: false
}
}
}
const IndexPage: NextPage<Props> = ({authenticated}) => {
return <div></div>
}
export default IndexPage;