vuetify-admin
vuetify-admin copied to clipboard
Error in JWT auth provider
The CHECK_AUTH method in the JWT auth provider returns response.data
, when a "user" route is provided in configuration.
/**
* Get user infos
*/
if (routes.user) {
let response = await httpClient.get(routes.user);
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
return response.data;
}
But then in store/auth.js it's commiting the "setUser" mutation using response.data
as a parameter again:
[CHECK_AUTH]: async ({ commit }) => {
try {
let response = await provider[CHECK_AUTH]();
if (response) {
commit("setUser", response.data);
}
return response.data;
} catch (e) {
commit("setUser", null);
}
},
This means incoming data from the axios request would have to be response.data.data. I believe that's an error. In store/auth.js it should just commit "setUser" with the parameter response
, since it's already containing the user data at this point.
As is I'm getting redirected to the login screen despite logging in successfully (token is set in localStorage) whenever I set a route to get the "user" data from.