Updated redirect implementation
This commit is contained in:
@@ -35,6 +35,7 @@ import Select from "react-select";
|
||||
import {USER_TYPE_LABELS} from "@/resources/user";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
debugger;
|
||||
const user = req.session.user;
|
||||
|
||||
const envVariables: {[key: string]: string} = {};
|
||||
@@ -45,14 +46,11 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
});
|
||||
|
||||
if (!user || !user.isVerified) {
|
||||
res.setHeader("location", "/login");
|
||||
res.statusCode = 302;
|
||||
res.end();
|
||||
return {
|
||||
props: {
|
||||
user: null,
|
||||
envVariables,
|
||||
},
|
||||
redirect: {
|
||||
destination: "/login",
|
||||
permanent: false,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,7 +59,13 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
};
|
||||
}, sessionOptions);
|
||||
|
||||
export default function Home({envVariables}: {envVariables: {[key: string]: string}}) {
|
||||
interface Props {
|
||||
user: any;
|
||||
envVariables: {[key: string]: string};
|
||||
}
|
||||
export default function Home(props: Props) {
|
||||
const { envVariables} = props;
|
||||
debugger;
|
||||
const [showDiagnostics, setShowDiagnostics] = useState(false);
|
||||
const [showDemographicInput, setShowDemographicInput] = useState(false);
|
||||
const [selectedScreen, setSelectedScreen] = useState<Type>("admin");
|
||||
|
||||
Reference in New Issue
Block a user