mirror of
https://github.com/dborth/vbagx.git
synced 2025-01-15 20:19:07 +01:00
Min adjust
This commit is contained in:
parent
4b727b21bf
commit
d4a9ed07a0
@ -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++) {
|
||||
|
@ -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;
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user