I'm using the auth module (version 5.0) provided by the nuxt community to log users in to my laravel sanctum backend. I know version 5.0 is still under development, but I'm hoping someone might know the answer to my question.
Basically to register to my backend, I make a GET request to /sanctum/csrf-cookie to first get a csrf cookie. After that I register the user. Now according to my backend the user that made the request is logged in directly after registration was successfull.
How do I properly tell the auth module that the user is logged in? I tried setting the user but that was without success.
this.$axios.get('/sanctum/csrf-cookie').then(() => {
this.$axios.$post('/register', formData).then(({ user }: any) => {
this.$auth.setUser(user);
console.log(this.$auth.user); // actually returns the user
console.log(this.$auth.loggedIn); // returns false
}).then(() => {
this.$auth.fetchUser().then(data => console.log(data)); // returns undefined (could be because the user already exists in memory?)
});
});