drafted materio_sapi search block vue integration
This commit is contained in:
@@ -13,7 +13,8 @@ export default {
|
||||
token: null,
|
||||
logout_token: null,
|
||||
isloggedin: false,
|
||||
isAdmin: false
|
||||
isAdmin: false,
|
||||
canSearch: false
|
||||
},
|
||||
|
||||
// getters
|
||||
@@ -38,25 +39,35 @@ export default {
|
||||
state.uuid = data.uuid[0].value
|
||||
},
|
||||
setRoles (state, roles) {
|
||||
console.log("User setRoles", roles);
|
||||
state.roles = []
|
||||
for (var i = 0; i < roles.length; i++) {
|
||||
state.roles.push(roles[i].target_id)
|
||||
}
|
||||
if(state.roles.indexOf('admin') != -1){
|
||||
console.log('is admin');
|
||||
// check if admin
|
||||
if(state.roles.indexOf('admin') != -1 || state.roles.indexOf('root') != -1){
|
||||
// console.log('is admin');
|
||||
state.isAdmin = true
|
||||
}
|
||||
// check if has access to search
|
||||
if(state.roles.indexOf('adherent') != -1){
|
||||
// console.log('is admin');
|
||||
state.canSearch = true
|
||||
}
|
||||
},
|
||||
setLoggedOut (state) {
|
||||
console.log("setLoggedOut state", state);
|
||||
state.uid= null
|
||||
state.mail = ''
|
||||
state.token = null
|
||||
state.isloggedin = false
|
||||
state.logout_token = null
|
||||
if (state.isAdmin){
|
||||
|
||||
window.location.reload(true);
|
||||
}
|
||||
state.asAdmin = false
|
||||
state.canSearch = false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -96,34 +107,19 @@ export default {
|
||||
if(data.roles){
|
||||
commit('setRoles', data.roles)
|
||||
}
|
||||
// JSONAPI.get(`/user/user/${state.uuid}?include=roles`)
|
||||
// .then(({ data }) => {
|
||||
// console.log('user JSONAPI getUser data', data)
|
||||
// })
|
||||
// .catch(( error ) => {
|
||||
// console.warn('Issue with getUser', error)
|
||||
// Promise.reject(error)
|
||||
// })
|
||||
})
|
||||
.catch(( error ) => {
|
||||
console.warn('Issue with getUser', error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
},
|
||||
// checkLoginRole ({ commit, state }){
|
||||
// console.log('checkLoginRole', state.roles, state.roles.indexOf('admin'))
|
||||
// if(state.roles.indexOf('admin') != -1){
|
||||
// console.log('is admin')
|
||||
// window.
|
||||
// }
|
||||
// },
|
||||
userLogout ({ commit, state }) {
|
||||
let credentials = qs.stringify({
|
||||
token: state.token
|
||||
})
|
||||
REST.post('/user/logout', credentials)
|
||||
.then((resp) => {
|
||||
console.log('resp', resp)
|
||||
console.log('userLogout resp', resp)
|
||||
commit('setLoggedOut')
|
||||
})
|
||||
.catch(( error ) => {
|
||||
|
Reference in New Issue
Block a user