This commit is contained in:
Matej Glasnák committed 2023-01-19 12:22:57 +01:00
1 parent ae33df38e4
commit 012a9ec926
5 files changed
+10 -4

No files matched your search

@@ -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) {
@@ -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)
@@ -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) {
+3 -1
View File
@@ -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
}
}
}
+4
View File
@@ -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']}`