From 0d50cad31322f800b8800b5da105d3395398aac8 Mon Sep 17 00:00:00 2001 From: Juan Carlos Ruvalcaba Date: Fri, 30 Apr 2021 20:47:51 -0700 Subject: [PATCH] Min refactor on user login --- src/js/stores/user.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/js/stores/user.js b/src/js/stores/user.js index 9d4cc68..3402f64 100644 --- a/src/js/stores/user.js +++ b/src/js/stores/user.js @@ -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');