Hello
I have a very strange error that I can't seem to find a solution for. Have built a vue 3 application that uses directus to authenticate.
I have two different users and try to log in and log out even though I logged out the first user, I get his information in response when I log in as user 2?
I use the directus SDK..
Here is the login function:
async login({ email, password }) {
try {
await directus.auth.login({
email,
password,
})
// If login was successful, fetch the users data
const user = await directus.users.me.read({
fields: ['id', 'email', 'first_name', 'last_name', 'avatar', 'role'],
})
console.log(user)
// Update the auth store with the user data
this.loggedIn = true
this.user = user
// Redirect to home page
this.router.push(this.returnUrl || '/')
} catch (e) {
console.error(e.message)
throw new Error('Fel användarnamn eller lösenord. Prova igen!')
}
},
Logout function:
async logout() {
try {
await directus.auth.logout()
this.$reset()
// Remove rest in localstorage
localStorage.clear()
this.router.push('/login')
} catch (e) {
console.error(e.message)
throw new Error('Något blev fel vid utloggningen.')
}
},
I invoking directus by:
import { Directus } from '@directus/sdk'
export const useDirectus = () => {
const directus = new Directus(import.meta.env.VITE_DIRECTUS_URL, { auth: { mode: 'json' } })
return directus
}