opnform/resources/js/middleware/auth.js

14 lines
282 B
JavaScript
Raw Normal View History

import { useAuthStore } from '../stores/auth';
2022-09-20 19:59:52 +00:00
import Cookies from 'js-cookie'
export default async (to, from, next) => {
const authStore = useAuthStore()
if (!authStore.check) {
2022-09-20 19:59:52 +00:00
Cookies.set('intended_url', to.path)
next({ name: 'login' })
} else {
next()
}
}