Vue plugin for easily managing your app's auth state
This is a work in progress and the API may change without notice
npm install vue-auth --save
Looking for Vue 2 support?
npm install vue-auth@next --save
var Vue = require('vue')
var VueAuth = require('vue-auth')
Vue.use(VueAuth)
To access the auth object you'll find the $auth
property on your application instance. (e.g this.$auth.getToken()
)
storagePrefix
- Prefix to the storage keys used in localStorageauthPath
- URI the user should be redirected to to re-authenticateredirectType
- May be eitherrouter
orbrowser
. Which method should the user be redirected with?
Setting options is done the same as all Vue plugins.
Vue.use(VueAuth, {
storagePrefix: '_prefix.',
redirectType: 'browser'
})
getToken()
setToken(token)
removeToken()
hasToken()
isAuthenticated()
getUserData()
setUserData(data)
Copyright (c) 2016 Wade Urry - Released under the MIT Licence