Ocelot-Social/webapp/middleware/termsAndConditions.js
2019-11-16 14:34:23 +01:00

21 lines
559 B
JavaScript

import isEmpty from 'lodash/isEmpty'
export default async ({ store, env, route, redirect }) => {
const publicPages = env.publicPages
// only affect non public pages
if (publicPages.indexOf(route.name) >= 0) {
return true
}
if (route.name === 'terms-and-conditions-confirm') return true // avoid endless loop
if (store.getters['auth/termsAndConditionsAgreed']) return true
const params = {}
if (!isEmpty(route.path) && route.path !== '/') {
params.path = route.path
}
return redirect('/terms-and-conditions-confirm', params)
}