Restrict location page access to matching country slug from param
Location page would be accessible if the country page param was set to anything else than the country it should be linked to from the data
This commit is contained in:
@@ -25,7 +25,7 @@ export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutp
|
|||||||
filter: {
|
filter: {
|
||||||
slug: { _eq: "${slug}" },
|
slug: { _eq: "${slug}" },
|
||||||
status: { _eq: "published" },
|
status: { _eq: "published" },
|
||||||
}
|
},
|
||||||
) {
|
) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@@ -41,7 +41,10 @@ export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutp
|
|||||||
website
|
website
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
country { name }
|
country {
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
}
|
||||||
has_poster
|
has_poster
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +65,9 @@ export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
const { data: { location, photos, total_published } } = res
|
const { data: { location: location, photos, total_published }} = res
|
||||||
|
|
||||||
if (!location.length) {
|
if (params.country !== location[0].country.slug || !location.length) {
|
||||||
return { status: 404 }
|
return { status: 404 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user