Made sure the user can’t navigate to another page when they shouldn’t via the URL
This commit is contained in:
@@ -21,6 +21,7 @@ import {calculateBandScore} from "@/utils/score";
|
||||
import {BsBook, BsHeadphones, BsMegaphone, BsPen} from "react-icons/bs";
|
||||
import Select from "react-select";
|
||||
import useGroups from "@/hooks/useGroups";
|
||||
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
const user = req.session.user;
|
||||
@@ -36,6 +37,17 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (shouldRedirectHome(user)) {
|
||||
res.setHeader("location", "/");
|
||||
res.statusCode = 302;
|
||||
res.end();
|
||||
return {
|
||||
props: {
|
||||
user: null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
props: {user: req.session.user},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user