I try to pass my project create on linux to a windows but i got a problem. In my project i got a DB and all is fine, i can sign in and in my table i see my account.
Now my login function in auth.js (store)
async login({ dispatch }, credentials){
let response = await axios.post(`/api/auth/connexion`, credentials);
if(!response.data.error){
dispatch('attempt', response.data.token).then((resp)=> {
if(resp){
dispatch('message/resetState', null , {root: true});
router.push({ name: 'Home', query: {category: 'home'} });
}
});
}else {
dispatch('message/setError', response.data.error , {root: true});
}
}
And my dispatch('attempt', response.data.token) ;
async attempt({ commit, state }, token) {
if(token){
commit('SET_TOKEN', token);
}
if (!state.token){
return
}
try{
let response = await axios.get(`/api/auth/me`);
commit('SET_USER', response.data);
response = await axios.get(`/api/auth/isAdmin`);
commit('SET_ADMIN', response.data);
return true;
}
catch(err){
commit('SET_TOKEN', null);
commit('SET_USER', null);
commit('SET_ADMIN', null);
}
}
If i console.log token in is printed, but ir the :
await axios.get(`/api/auth/me`)
Don't works and i found why, it's because my method login and signin is in except middleware :
$this->middleware('auth:api', ['except' => ['login', 'register']]);
My question is :
Why my auth middleware is not setup and not work ??
This project work fine on my other pc on linux. Thanks for help !