Min adjust

This commit is contained in:
Juan Carlos Ruvalcaba 2021-04-21 12:48:40 -07:00
parent 4b727b21bf
commit d4a9ed07a0
2 changed files with 12 additions and 11 deletions

View File

@ -16,7 +16,7 @@ let Check = {
const router = this;
const userData = JSON.parse(localStorage.getItem("userData"));
const userRoles = userData['userPermissions'];
//const userRoles = localStorage.getItem("roles");
//const userRoles = user.roles.value;
let currentIndex = -1;
for (let i = 0; i < router.routes.length; i++) {

View File

@ -18,15 +18,13 @@ const user = createStore({
const user = response.data.user;
const roles = response.data.roles;
localStorage.setItem('token', token);
localStorage.setItem('roles', roles);
http.defaults.headers.common['Authorization'] = token;
dispatch('auth_success', token, user);
dispatch('auth_success', token, user, roles);
resolve(response);
})
.catch(err => {
dispatch('auth_error');
localStorage.removeItem('token');
localStorage.removeItem('roles');
reject(err);
});
});
@ -34,7 +32,6 @@ const user = createStore({
logOut(){
return new Promise((resolve, reject) => {
dispatch('logout');
localStorage.removeItem('token');
localStorage.removeItem('roles');
http.defaults.headers.common['Authorization'];
resolve();
@ -46,12 +43,13 @@ const user = createStore({
state.token = '';
},
auth_request(state){
state.status = 'loading'
state.status = 'loading';
},
auth_success(state, token, user){
state.status = 'success'
state.token = token
state.user = user
auth_success(state, token, user, roles){
state.status = 'success';
state.token = token;
state.user = user;
state.roles = roles;
},
auth_error(state){
state.status = 'error'
@ -64,7 +62,10 @@ const user = createStore({
},
authStatus({ state }) {
return state.status;
}
},
roles({ state }){
return state.roles;
},
},
})