Commit a1ee6e9e authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

add middleware home

parent d1a55c84
......@@ -54,8 +54,10 @@ export default {
token: this.$auth.$storage.getUniversal('token'),
}),
});
localStorage.removeItem("token");
localStorage.setItem("token",'');
this.$auth.$storage.setUniversal("loggedIn", 'false');
this.$auth.$storage.setUniversal("token", '');
this.$auth.$storage.setUniversal("userName", '');
this.$router.push("/");
},
},
......
const token_access = localStorage.getItem('token');
export default function ({ redirect }) {
if (!token_access) {
// this.$router.push('/')
console.log('[LOG]: running ...');
}
}
\ No newline at end of file
export default ({ redirect }) => {
console.log('[LOG]: middleware is running ...')
if (localStorage.getItem("token")=="") {
return redirect('/')
}
};
\ No newline at end of file
......@@ -57,7 +57,7 @@ export default {
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
},
router: {
middleware: 'web'
}
// router: {
// middleware: 'web'
// }
}
......@@ -22,8 +22,10 @@ import Footer from "@/components/footer";
export default {
components: { Nav },
components: { Footer },
middleware: ['web'],
};
</script>
<style></style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment