dev #1

Merged
sauceyred merged 36 commits from dev into main 2025-05-29 03:01:50 +00:00
Showing only changes of commit 6a11108ec1 - Show all commits

17
middleware/auth.global.ts Normal file
View file

@ -0,0 +1,17 @@
export default defineNuxtRouteMiddleware(async (to, from) => {
console.log("to.path:", to.path);
const accessToken = useCookie("access_token").value;
if (["/login", "/register"].includes(to.path)) {
if (accessToken) {
return await navigateTo("/");
}
return;
};
if (!accessToken) {
const { refresh } = useAuth();
console.log("hi");
await refresh();
return await navigateTo("/login");
}
})