refactor(client-side): update story check middleware

if fetching a story returns an error, check that the error code is 403 (forbidden) as well before redirecting
This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2024-12-08 23:22:40 -05:00
parent 80dbd05468
commit e6ba48dc2f
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

View File

@ -14,7 +14,7 @@ export const storyMiddleware = defineNuxtRouteMiddleware(async (to, from) => {
console.log("to n from", to, from, data); console.log("to n from", to, from, data);
const { data: story, error } = await useApiFetch<SingleChapterResult>(to.path); const { data: story, error } = await useApiFetch<SingleChapterResult>(to.path);
if (error.value) { if (error.value) {
if (error.value.message.toLocaleLowerCase() == "unauthenticated") { if (error.value.message.toLocaleLowerCase() == "unauthenticated" || error.value.statusCode == "403") {
return navigateTo("/auth/login"); return navigateTo("/auth/login");
} }
return showError(error.value); return showError(error.value);