vue-jwt-auth
raw JSON → 0.12.4-moved verified Sat Apr 25 auth: no javascript renamed
This package is deprecated and has been moved to @websanova/vue-auth. The last version is 0.12.4-moved. It was a Vue.js JWT authentication plugin providing login, logout, token storage, and HTTP interceptors. It is replaced by the more feature-rich @websanova/vue-auth package which supports multiple authentication types (JWT, OAuth, etc.) and drivers (axios, fetch, etc.). Do not use this package; migrate to @websanova/vue-auth.
Common errors
error Cannot find module 'vue-jwt-auth' ↓
cause Package renamed or not installed.
fix
Use npm install @websanova/vue-auth instead.
error TypeError: VueJwtAuth is not a constructor ↓
cause Using new VueJwtAuth() instead of Vue.use().
fix
Use Vue.use(VueJwtAuth, options).
Warnings
deprecated vue-jwt-auth is deprecated and renamed to @websanova/vue-auth ↓
fix Migrate to @websanova/vue-auth.
breaking The package has been completely rewritten. API interface is different from vue-jwt-auth. ↓
fix Read the documentation of @websanova/vue-auth for new API.
Install
npm install vue-jwt-auth yarn add vue-jwt-auth pnpm add vue-jwt-auth Imports
- VueJwtAuth wrong
import { VueJwtAuth } from 'vue-jwt-auth'correctimport VueJwtAuth from 'vue-jwt-auth' - Vue.use(VueJwtAuth, options) wrong
new VueJwtAuth(options)correctVue.use(VueJwtAuth, options) - this.$auth wrong
this.$auth.login(credentials).catch(...)correctthis.$auth.login(credentials)
Quickstart
import Vue from 'vue';
import VueJwtAuth from 'vue-jwt-auth';
Vue.use(VueJwtAuth, {
register: '/api/register',
login: '/api/login',
logout: '/api/logout',
auth: '/api/user',
token: '/api/token',
refresh: '/api/refresh',
token_type: 'Bearer',
token_name: 'access_token',
refresh_token_name: 'refresh_token',
auth_redirect: '/login',
login_redirect: '/dashboard',
register_redirect: '/dashboard',
logout_redirect: '/login',
forbidden_redirect: '/401',
not_found_redirect: '/404',
forbidden_page: '/401',
not_found_page: '/404'
});
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app');