Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function({ store, error, redirect, route }) {
if (!store.state.auth.user) {
redirect('/login')
}
if (
!route.path.includes('teacher') &&
store.state.auth.user.role === 'teacher'
) {
Toast.open('Usuario nao autorizado')
redirect('/login')
}
}
export default function({ store, redirect }) {
if (!store.state.courseTag) {
const currentUser = store.state.auth.user
Toast.open('Selecione um Curso')
if (currentUser.role === 'admin') {
redirect('/')
} else if (currentUser.role === 'teacher') {
redirect('/teacher/home')
}
}
}
$axios.onError(error => {
const code = parseInt(error.response && error.response.status)
if (
code === 400 &&
error.response.data.code === process.env.errors.INVALID_TOKEN
) {
Toast.open({
type: 'is-danger',
message: 'Login expirado',
duration: 5000
})
store.dispatch('auth/logout')
redirect('/login')
} else if (error.message === 'Network Error') {
Toast.open({
type: 'is-danger',
message: 'Ocorreu um erro na conexão'
})
} else {
throw error
}
})
}