WIP
This commit is contained in:
18
client/stores/auth.js
vendored
18
client/stores/auth.js
vendored
@@ -1,5 +1,6 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import axios from 'axios'
|
||||
import {useOpnFetch} from "~/composables/useOpnFetch.js";
|
||||
|
||||
export const useAuthStore = defineStore('auth', {
|
||||
state: () => {
|
||||
@@ -41,15 +42,18 @@ export const useAuthStore = defineStore('auth', {
|
||||
},
|
||||
|
||||
async fetchUser() {
|
||||
try {
|
||||
const {data} = await axios.get('/api/user')
|
||||
this.user = data
|
||||
useOpnFetch('/user').then(({data, error}) => {
|
||||
console.log('fetch user', data,error)
|
||||
if (error.value) {
|
||||
console.error('Error fetching user', error.value)
|
||||
this.setToken(null)
|
||||
}
|
||||
|
||||
this.user = data.value
|
||||
this.initServiceClients()
|
||||
|
||||
return data
|
||||
} catch (e) {
|
||||
this.setToken(null)
|
||||
}
|
||||
return this.user
|
||||
})
|
||||
},
|
||||
|
||||
async fetchUserIfNotFetched() {
|
||||
|
||||
5
client/stores/workspaces.js
vendored
5
client/stores/workspaces.js
vendored
@@ -71,8 +71,9 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
load() {
|
||||
this.set([])
|
||||
this.startLoading()
|
||||
return useOpnFetch(workspaceEndpoint).then((response) => {
|
||||
this.set(response.data)
|
||||
return useOpnFetch(workspaceEndpoint,{server: false}).then(({data,error}) => {
|
||||
console.log(data,error)
|
||||
this.set(data)
|
||||
this.stopLoading()
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user