Skip to content

Commit

Permalink
locale
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Aug 19, 2024
1 parent 4d94088 commit 0b7051f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/pages/auth/mfaRecovery/reset/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import { useRouter } from "next/router";
import { api } from "~/utils/api";
import { Session } from "next-auth";
import { toast } from "react-hot-toast";
import { type ErrorData, type ZodErrorFieldErrors } from "~/types/errorHandling";
import Head from "next/head";
Expand All @@ -9,6 +10,8 @@ import FormInput from "~/components/auth/formInput";
import FormSubmitButtons from "~/components/auth/formSubmitButton";
import { ErrorCode } from "~/utils/errorCode";
import { useTranslations } from "next-intl";
import { GetServerSideProps, GetServerSidePropsContext } from "next";
import { getSession } from "next-auth/react";

const MfaRecoveryReset = () => {
const t = useTranslations();
Expand Down Expand Up @@ -181,4 +184,33 @@ const MfaRecoveryReset = () => {
);
};

interface Props {
auth?: Session["user"];
}
export const getServerSideProps: GetServerSideProps<Props> = async (
context: GetServerSidePropsContext,
) => {
const session = await getSession(context);
if (!session || !("user" in session) || !session.user) {
return {
props: {
messages: (await import(`~/locales/${context.locale}/common.json`)).default,
},
};
}

if (session.user) {
return {
redirect: {
destination: "/network",
permanent: false,
},
};
}

return {
props: { auth: session.user },
};
};

export default MfaRecoveryReset;

0 comments on commit 0b7051f

Please sign in to comment.