0

I note that with the auth module, after a successful log in, it hits a /user endpoint to get user information.

The documentation states that you can remove this extra request by changing the configuration, and returning the user information in the initial log in request.

But the documentation state:

The auth module does not persist information about the user, so there needs to be a way to fetch the user's information on e.g. page reload.

But if I return the users details with the initial log in request, are these not stored in the Vuex store? And therefore I do not need to have a /user endpoint?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
panthro
  • 22,779
  • 66
  • 183
  • 324
  • The `user.property` is the actual value the module will look into by default, without you needing to set it by default. If you handle it youself, you can set it to `false`. Also, Vuex is not a persistance solution but a volatile store. If you hit reload, it will be wiped out. I do recommend using cookies to store the JWT access_token of your user locally. That way, on reload you will be able to auto-login the user thanks to this (if it is not expired, otherwise a `refresh_token` is also a possibility). Luckily, the persistance can also be done easily with the auth module. – kissu Jan 11 '22 at 15:54
  • Thank you for your comment, I still do not completely understand the setup, do you know of any tutorials? All the tutorials I have found insist on using /user – panthro Jan 11 '22 at 16:24
  • I don't really have a tutorial on this one, meanwhile [here are some](https://stackoverflow.com/search?q=user%3A8816585+%5Bnuxt-auth%5D) of the questions I've already answered to. – kissu Jan 11 '22 at 16:26
  • you can look into using some plugin that would keep a part of your vuex (as cookie or localstorage) like https://www.npmjs.com/package/vuex-persistedstate – Jimmar Jan 11 '22 at 23:54

0 Answers0