I'm currently working on integrating my VueJS SPA with a Laravel API.
I came across a plugin called vue-auth that seems to be perfect for handling role-based authentication:
Here's the Github link: https://github.com/websanova/vue-auth
And here's the documentation link:
While the plugin seems to meet my requirements, I'm facing challenges in implementing it in my application.
import Vue from 'vue';
import auth from '@websanova/vue-auth';
import authBearer from '@websanova/vue-auth/drivers/auth/bearer.js';
import httpAxios from '@websanova/vue-auth/drivers/http/axios.1.x.js';
import routerVueRouter from '@websanova/vue-auth/dist/drivers/router/vue-router.2.x.js';
Vue.use(auth, {
auth: authBearer,
http: httpAxios,
router: routerVueRouter,
rolesKey: 'role'
});
However, when I try to use my application, I encounter this error message in my console:
Uncaught TypeError: Cannot read property 'beforeEach' of undefined
at Auth.beforeEach
at _initInterceptors
at new Auth
Interestingly, when I switch to using the vue-resource as the http driver (as per the documentation), I face another error:
Uncaught TypeError: Cannot read property 'interceptors' of undefined
at Auth.interceptor
at _initInterceptors
at new Auth
I've been stuck for a few hours now and despite searching extensively on the internet, I haven't found a working solution.
Thank you for taking the time to read this.