0.0.7 • Published 8 years ago

vue-identity v0.0.7

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

vue-identity

vue-identity is a vue plugin that uses JSON Web Tokens to make authentication easy.

Installation

NPM

$ npm install vue-identity

Example

import VueIdentity from 'vue-identity'
Vue.use(VueIdentity, {
    url: "/auth", // full url to your auth endpoint
})

Authenticate

This will ask the server for an accessToken by passing it a refreshToken. Cookies are sent with this request if you prefer.

this.$identity.authenticate().then(function(){ console.log( "Logged in!" ) })

Login

Request a new accessToken and refreshToken by passing credentials to the server. Credentials are sent as parameters of login and are POSTed to the server.

this.$identity.login({user: "salty",password:"quark"}).then(function(){ console.log( "Logged in!" ) })

In your html, you can access the user state

<div v-if="$identity.user">
  <p>Hello {{$identity.user.name}}</p>
</div>

Vue Resource Interceptor

After authenticating, an interceptor is added to vue-resource that sends the accessToken in the Authorization header as a Bearer token.

Documentation

License

MIT

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago