Add roles check to the guards verifyLogin.

This commit is contained in:
elweyn 2023-07-23 11:10:12 +02:00
parent bed2b86ea5
commit 1a4c42ea26

View File

@ -13,8 +13,10 @@ const addNavigationGuards = (router, store, apollo, i18n) => {
})
.then((result) => {
const moderator = result.data.verifyLogin
if (moderator.isAdmin) {
if (moderator.roles.includes('ADMIN', 0) || moderator.roles.includes('MODERATOR', 0)) {
i18n.locale = moderator.language
moderator.isAdmin = moderator.roles.includes('ADMIN', 0)
moderator.isModerator = moderator.roles.includes('MODERATOR', 0)
store.commit('moderator', moderator)
next({ path: '/' })
} else {
@ -35,7 +37,7 @@ const addNavigationGuards = (router, store, apollo, i18n) => {
!CONFIG.DEBUG_DISABLE_AUTH && // we did not disabled the auth module for debug purposes
(!store.state.token || // we do not have a token
!store.state.moderator || // no moderator set in store
!store.state.moderator.isAdmin) && // user is no admin
!(store.state.moderator.isAdmin || store.state.moderator.isModerator)) && // user is no admin
to.path !== '/not-found' && // we are not on `not-found`
to.path !== '/logout' // we are not on `logout`
) {