Intevel/nuxt-directus

bug on auth

Closed this issue · 11 comments

I am developing a little project based on nuxt 3 and Directus.

There is a problem when i'm trying to login logout. When i call login method, the user is fetch and setted and same for token and when i logout, i have the user and the token as undefined. But when i retry login with other user, the useDirectusUser returns last user and not new one. I don't know why but it's a real problem.

PS/ To avoid the problem and have new user, i have to refresh the page.

Hey @DeltaCorporate, can you provide a reproduction?

yeah it's simple, try just this:
1- login to a first user
2- logout this user
3- login to second user
You will see that's the user isn't updated on store

but if you refresh page after second user login, you'll have correct informations.

@DeltaCorporate should be fixed with v3.2.1

@Intevel Hello the problem still persist. What I do to bypass this problem by myself is to request directly the api with /users/me?access_token=xxxxxx.
This works correctly. You have also to use useFetch instead of other implemented request methods because it's the only one which not have any cache request. The problem come because of this request cache.

const {data} = await useFetch("https://api.example.com/users/me", { method: "GET", params: { access_token } }) // @ts-ignore return data._rawValue.data; }

Okay, I'll try to find out what the problem is. It should not be $fetch, useFetch uses $fetch under the hood

I think that is a problem of reactivity, maybe we should switch to another store like Pinia or nuxt-session.

@DeltaCorporate Can you maybe provide a CodeAndSandbox or something as reproducion, I can't reproduce this anymore.

Hi bro, i'm so sorry that's my error, i retryed without updating the plugin lol. I'm really sorry for that inconvenience. But a little question. Why the useDirectusUser only returns id? is it for security issue?

No, that's part of Directus. You have to update the rights of your directus application.

Ok thank the updated plugins works fine. Good work and sorry for reopening this ticket