Logout if there is no token
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
export default defineNuxtRouteMiddleware(() => {
|
||||
const { token } = useAuth();
|
||||
import { useAuth } from "~/composables/api/auth/useAuth";
|
||||
|
||||
if (token.value) {
|
||||
export default defineNuxtRouteMiddleware(() => {
|
||||
const { token, logout } = useAuth();
|
||||
|
||||
if (!!token.value) {
|
||||
return;
|
||||
} else {
|
||||
logout();
|
||||
return navigateTo("/signin");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user