This commit is contained in:
@@ -3,10 +3,11 @@ export default defineNuxtRouteMiddleware(async (to, _from) => {
|
||||
|
||||
const code = to.query.code;
|
||||
if (to.path === "/poll") {
|
||||
console.log(`${runtimeConfig.public.apiBase}/check/${code}`)
|
||||
const { error } = await useFetch(`${runtimeConfig.public.apiBase}/check/${code}`);
|
||||
if (error.value && error.value.statusCode !== 200) {
|
||||
if(error.value.statusCode == 403){
|
||||
return navigateTo({path:"/results", query:to.query});
|
||||
return navigateTo({path:"/finished", query:to.query});
|
||||
}
|
||||
throw createError({
|
||||
statusCode: error.value.statusCode,
|
||||
@@ -17,7 +18,18 @@ export default defineNuxtRouteMiddleware(async (to, _from) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if(to.path === "/finished"){
|
||||
return
|
||||
}
|
||||
|
||||
if(to.path === "/results"){
|
||||
if(code != "fc6d9f50-68af-4df5-95d4-36745c2938c9"){
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Invalid code",
|
||||
message: "Vous ne pouvez pas accéder aux résultats avec ce code !"
|
||||
});
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user