updated authentication on protected pages
This commit is contained in:
@@ -15,7 +15,8 @@ import { useState } from "react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import jsonpath from "jsonpath";
|
||||
import { reduxForm, formValueSelector } from "redux-form";
|
||||
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import NoSessionWarning from "../../components/nosession";
|
||||
import RegisterForm from "../../components/account/registerform";
|
||||
|
||||
const Home = (props) => {
|
||||
@@ -29,6 +30,17 @@ const Home = (props) => {
|
||||
const [registerFormComplete, setRegisterFormComplete] = useState(false);
|
||||
const [accountCreatedComplete, setAccountCreatedComplete] = useState(false);
|
||||
|
||||
const { data: session, status } = useSession();
|
||||
|
||||
if (status === "loading") {
|
||||
return <NoSessionWarning loading={true} />;
|
||||
}
|
||||
|
||||
if (status === "unauthenticated") {
|
||||
router.push("/auth/signin");
|
||||
return <NoSessionWarning />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
|
||||
Reference in New Issue
Block a user