diff --git a/app/src/plugins/app/_layout/app/_components/a-header.vue b/app/src/plugins/app/_layout/app/_components/a-header.vue index 6d4669f..c4eb833 100644 --- a/app/src/plugins/app/_layout/app/_components/a-header.vue +++ b/app/src/plugins/app/_layout/app/_components/a-header.vue @@ -85,7 +85,7 @@ export default { methods: { async logOut() { try { - await this.$store.dispatch('wAuth/logout') + await this.$store.dispatch('auth/logout') this.$router.push('/') this.$toast.success('Boli ste odhlásený') } catch (error) { diff --git a/app/src/plugins/lib@auth/login/_components/a-login-form.vue b/app/src/plugins/lib@auth/login/_components/a-login-form.vue index 68e341f..a3764cc 100644 --- a/app/src/plugins/lib@auth/login/_components/a-login-form.vue +++ b/app/src/plugins/lib@auth/login/_components/a-login-form.vue @@ -41,7 +41,7 @@ export default { if (!(await this.v$.$validate())) return console.log(this.v$) try { - await this.$axios.post_data('v1/auth/login', this.form) + await this.$store.dispatch('auth/login', this.form) this.$router.push({ name: 'Overview - Ongoing tasks'}) } catch (error) { this.$toast.error(error) diff --git a/app/src/plugins/tm@profile/profile/my-profile.vue b/app/src/plugins/tm@profile/profile/my-profile.vue index 20fe826..e4f56d9 100644 --- a/app/src/plugins/tm@profile/profile/my-profile.vue +++ b/app/src/plugins/tm@profile/profile/my-profile.vue @@ -99,7 +99,7 @@ export default { async updateUserInfo() { if (!(await this.v$.$validate())) return try { - await this.$store.dispatch('wAuth/updateUserInfo', this.user) + await this.$store.dispatch('auth/updateUserInfo', this.user) this.$toast.success('Profil bol úspešne zmenený') } catch (error) { diff --git a/app/src/plugins/w/auth/auth.store.ts b/app/src/plugins/w/auth/auth.store.ts index 1a378ed..5348e84 100644 --- a/app/src/plugins/w/auth/auth.store.ts +++ b/app/src/plugins/w/auth/auth.store.ts @@ -18,6 +18,8 @@ export default { state.user = data.user localStorage.setItem('wzo_vue_user_user', JSON.stringify(data.user)) } + + console.log(state) }, auth_error(state: any) { state.token = '' @@ -158,7 +160,7 @@ export default { return state.user }, token: (state: any) => { - return state.token + return (state.token && state.token != undefined) ? state.token : null } } } \ No newline at end of file diff --git a/app/src/plugins/w/axios/models/axios.ts b/app/src/plugins/w/axios/models/axios.ts index 492ef97..7eefda8 100644 --- a/app/src/plugins/w/axios/models/axios.ts +++ b/app/src/plugins/w/axios/models/axios.ts @@ -149,6 +149,10 @@ export default { _config(config: any) { if (config) console.error('NOT IMPLEMENTED') + if (!store.getters['auth/token']) { + return {headers: {}} + } + return { headers: { Authorization: `Bearer ${store.getters['auth/token']}`