Merge pull request #3 from askotx/appserv

Min refactor on user login
This commit is contained in:
Juan Carlos Ruvalcaba 2021-04-30 20:48:31 -07:00 committed by GitHub
commit 6fa8f01f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,12 +38,13 @@ const user = createStore({
dispatch('auth_request');
try {
const response = await http.post('/user/login', data);
const token = response.data.token;
http.defaults.headers.common['Authorization'] = response.data.token;
await dispatch('setBasicData', response.data );
delete response.data.token;
const user = response.data.user;
const roles = response.data.roles; //[1, 4, 14]; //Owner, Customer, Seller, Deliverer
http.defaults.headers.common['Authorization'] = token;
await dispatch('setBasicData', { token, user, roles });
delete response.data.roles;
return response;
} catch (error) {
dispatch('auth_error');