How does @ websanova/vue-auth, the vue verification plug-in, work? Some of the official documents are difficult to understand.

Aug.27,2021

laxative ~
the following is excerpted from the link to the question,

@ websanova/vue-auth is the library that the client handles authentication. It injects a $auth object to provide many useful functions: for example, register () handles user registration, login (), handles user login, user (), accesses the currently logged-in user data, logout (), handles exit operations, and so on.

install the library first:

npm install @ websanova/vue-auth
Edit resources/assets/js/app.js: again

import Vue from 'vue';
.
Vue.use (require (' @ websanova/vue-auth'), {
auth: require ('@ websanova/vue-auth/drivers/auth/bearer.js'),
http: require ('@ websanova/vue-auth/drivers/http/axios.1.x.js'),
router: require ('@ websanova/vue-auth/drivers/router/vue-router.2.x.js'),
});
App.router = Vue.router
new Vue (App). $mount ('- sharpapp');
in the new code, we first introduce the newly installed library and do some configuration:
use bearer to add authentication token to the request header during the request. So that the server can read and parse this token:
auth: require ('@ websanova/vue-auth/drivers/auth/bearer.js')
configure vue-auth to use axios to send HTTP requests:
http: require ('@ websanova/vue-auth/drivers/http/axios.1.x.js')
We also configure vue-auth to use vue-router:
router: require ('@ websanova/vue-auth/drivers/router/vue-router.2.x.js')
finally, Notice the
meta: {auth: true}
configuration, which is used to specify whether the access route requires authentication. For more information on
, visit the @ websanova/vue-auth Github repository.

this is not very detailed, you can't understand what exactly it means? My advice is, first of all, you need to know what vue-auth is for, what problems are used to solve, and do you need it in this project?

Menu