You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
469 B
17 lines
469 B
|
6 years ago
|
import store from '@/store'
|
||
|
|
|
||
|
|
export function needAuth(route) {
|
||
|
|
if (route.path.startsWith('/redirect')) return false
|
||
|
|
return !(route.meta && (!('noAuth' in route) || route.meta.noAuth))
|
||
|
|
}
|
||
|
|
|
||
|
|
export function auth(path) {
|
||
|
6 years ago
|
if (store.state.user.admin === true) return true
|
||
|
6 years ago
|
|
||
|
6 years ago
|
const resourceMap = store.state.resource.dataMap
|
||
|
|
if (!(path in resourceMap)) return true
|
||
|
6 years ago
|
|
||
|
6 years ago
|
const resources = store.state.user.resources
|
||
|
6 years ago
|
return resources && path in resources
|
||
|
|
}
|