👌 IMPROVE: API et frontend /admin + API https
This commit is contained in:
@ -16,10 +16,6 @@ const Admin = (props) => {
|
||||
|
||||
const toggleModal = () => setIsOpen(!isOpen);
|
||||
|
||||
if (!props.user.isAdmin && typeof window != 'undefined') {
|
||||
return redirect({}, '/404');
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<HeadTag title="Admin - FunctionProject" description="Page d'administration de FunctionProject." />
|
||||
@ -66,12 +62,14 @@ const Admin = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({ req }) {
|
||||
const cookies = new Cookies(req.headers.cookie);
|
||||
export async function getServerSideProps(context) {
|
||||
const cookies = new Cookies(context.req.headers.cookie);
|
||||
const user = { ...cookies.get('user') };
|
||||
if (!user.isAdmin) {
|
||||
return redirect(context, '/404');
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
user: { ...cookies.get('user') }
|
||||
}
|
||||
props: { user }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -111,10 +111,6 @@ const manageCategories = (props) => {
|
||||
setIsEditing(true);
|
||||
toggleModal();
|
||||
}
|
||||
|
||||
if (!props.user.isAdmin && typeof window != 'undefined') {
|
||||
return redirect({}, '/404');
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@ -177,12 +173,14 @@ const manageCategories = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({ req }) {
|
||||
const cookies = new Cookies(req.headers.cookie);
|
||||
export async function getServerSideProps(context) {
|
||||
const cookies = new Cookies(context.req.headers.cookie);
|
||||
const user = { ...cookies.get('user') };
|
||||
if (!user.isAdmin) {
|
||||
return redirect(context, '/404');
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
user: { ...cookies.get('user') }
|
||||
}
|
||||
props: { user }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,6 @@ const manageQuotes = (props) => {
|
||||
if (node) observer.current.observe(node);
|
||||
}, [isLoadingQuotes, quotesData.hasMore]);
|
||||
|
||||
if (!props.user.isAdmin && typeof window != 'undefined') {
|
||||
return redirect({}, '/404');
|
||||
}
|
||||
|
||||
const handleValidationQuote = async (id, isValid) => {
|
||||
try {
|
||||
await api.put(`/admin/quotes/${id}`, { isValid }, { headers: { 'Authorization': props.user.token } });
|
||||
@ -112,12 +108,14 @@ const manageQuotes = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({ req }) {
|
||||
const cookies = new Cookies(req.headers.cookie);
|
||||
export async function getServerSideProps(context) {
|
||||
const cookies = new Cookies(context.req.headers.cookie);
|
||||
const user = { ...cookies.get('user') };
|
||||
if (!user.isAdmin) {
|
||||
return redirect(context, '/404');
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
user: { ...cookies.get('user') }
|
||||
}
|
||||
props: { user }
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user