diff --git a/src/components/cpmToolBar.vue b/src/components/cpmToolBar.vue index 688a2ce..194253f 100644 --- a/src/components/cpmToolBar.vue +++ b/src/components/cpmToolBar.vue @@ -64,7 +64,7 @@
- SAIR + SAIR
@@ -85,7 +85,8 @@ }), methods: { async logOff(){ - localStorage.removeItem('token') + await localStorage.removeItem('token'); + await localStorage.removeItem('id'); await this.$router.push('/') } diff --git a/src/store/modules/LoginVuex.js b/src/store/modules/LoginVuex.js index 3e1fa2c..c3bbceb 100644 --- a/src/store/modules/LoginVuex.js +++ b/src/store/modules/LoginVuex.js @@ -29,11 +29,11 @@ export default { }, - async authToken (context, newData) { + async authToken (context) { - const autho = await axios.post(process.env.VUE_APP_BASE_URL + '/user/authToken', newData + 'a') + const autho = await axios.post(process.env.VUE_APP_BASE_URL + '/user/authToken') - return autho + return autho.data; }, diff --git a/src/store/modules/ProfileVuex.js b/src/store/modules/ProfileVuex.js index ce620f4..3bc5dd2 100644 --- a/src/store/modules/ProfileVuex.js +++ b/src/store/modules/ProfileVuex.js @@ -20,12 +20,8 @@ export default { actions: { async getUser(context){ - const token = localStorage.getItem('token'); - const decodedToken = await axios.post(process.env.VUE_APP_BASE_URL+'/user/authToken', token); - - console.log(decodedToken) - - const user = await axios.get(process.env.VUE_APP_BASE_URL+`/user/mail/${decodedToken.data}`); + + const user = await axios.get(process.env.VUE_APP_BASE_URL+`/user/this`); return user.data; }, diff --git a/src/views/private/Profile.vue b/src/views/private/Profile.vue index 0069850..82a89d0 100644 --- a/src/views/private/Profile.vue +++ b/src/views/private/Profile.vue @@ -49,7 +49,7 @@ -
+
@@ -58,7 +58,7 @@
- SAIR + SAIR @@ -105,7 +105,12 @@ export default { getMyEvents: "ProfileVuex/getMyEvents", updateAvatar: "ProfileVuex/updateAvatar", }), + logOut(){ + localStorage.removeItem('token'); + localStorage.removeItem('id'); + this.$router.push('/Home'); + }, async loadUser() { const user = await this.getUser(); diff --git a/src/views/public/Login.vue b/src/views/public/Login.vue index 14a7ea2..4ea176e 100644 --- a/src/views/public/Login.vue +++ b/src/views/public/Login.vue @@ -40,8 +40,7 @@ export default { created() { if (localStorage.token) { - this.checkToken().then(() => this.$router.push('/Feed')) - + this.checkToken(); } }, @@ -84,15 +83,17 @@ export default { async checkToken() { - const isAuth = await this.authToken(localStorage.token) + const isAuth = await this.authToken(); - if (isAuth) { + if (isAuth != false) { this.$toast.success('Logado!', 'Hey', { position: "topCenter" }) this.$router.push('/Feed') } + + console.log(isAuth) } } }