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 { ...@@ -54,8 +54,10 @@ export default {
token: this.$auth.$storage.getUniversal('token'), token: this.$auth.$storage.getUniversal('token'),
}), }),
}); });
localStorage.removeItem("token"); localStorage.setItem("token",'');
this.$auth.$storage.setUniversal("loggedIn", 'false'); this.$auth.$storage.setUniversal("loggedIn", 'false');
this.$auth.$storage.setUniversal("token", '');
this.$auth.$storage.setUniversal("userName", '');
this.$router.push("/"); this.$router.push("/");
}, },
}, },
......
const token_access = localStorage.getItem('token'); export default ({ redirect }) => {
export default function ({ redirect }) { console.log('[LOG]: middleware is running ...')
if (!token_access) { if (localStorage.getItem("token")=="") {
// this.$router.push('/') return redirect('/')
console.log('[LOG]: running ...');
}
} }
};
\ No newline at end of file
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
// Build Configuration: https://go.nuxtjs.dev/config-build // Build Configuration: https://go.nuxtjs.dev/config-build
build: { build: {
}, },
router: { // router: {
middleware: 'web' // middleware: 'web'
} // }
} }
...@@ -22,8 +22,10 @@ import Footer from "@/components/footer"; ...@@ -22,8 +22,10 @@ import Footer from "@/components/footer";
export default { export default {
components: { Nav }, components: { Nav },
components: { Footer }, components: { Footer },
middleware: ['web'],
}; };
</script> </script>
<style></style> <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