@authllizer/vue
v0.2.0
Published
Vue Authllizer Plugin
Downloads
9
Maintainers
Readme
Vue Authllizer Plugin
This plugin is a wrapper of Authllizer for comfortable using it in VueJs.
Example
There are VueJs example project in the source code.
Install
$ npm install --save @authllizer/vue
# and install peer dependencies
$ npm install --save @authllizer/core
Setup
import Vue from 'vue';
import { default as VueAuthllizer } from '@authllizer/vue';
import { IAuthllizerOptions } from '@authllizer/core';
Vue.use(VueAuthllizer, {
// ...
} as IAuthllizerOptions);
Use
import Vue from 'vue';
import { Authllizer } from '@authllizer/core';
class SomeComponent extends Vue {
doSomething(){
let auth: Authllizer = this.$auth;
}
}
Http Client
You can use another library as http client see in the doc HttpClient.
vue-axios
import Vue from 'vue';
import { IAuthllizerOptions } from '@authllizer/core';
import VueAuthllizer, { VueAxiosHttpClient } from '@authllizer/vue';
import axios from 'axios';
import * as VueAxios from 'vue-axios';
Vue.use(VueAxios, axios);
Vue.use(VueAuthllizer, {
httpClient: new VueAxiosHttpClient
// ...
} as IAuthllizerOptions)
interceptor
import { VueAxiosTokenInterceptor } from '@authllizer/vue';
import Vue from 'vue';
Vue.axios.interceptors.request.use(VueAxiosTokenInterceptor);
vue-resource
import Vue from 'vue';
import { IAuthllizerOptions } from '@authllizer/core';
import VueAuthllizer from '@authllizer/vue';
import * as VueResource from 'vue-resource';
Vue.use(VueResource);
Vue.use(VueAuthllizer, {...} as IAuthllizerOptions);
interceptor
import { VueResourceTokenInterceptor } from '@authllizer/vue';
import Vue from 'vue';
Vue.resource.interceptors.push(VueResourceTokenInterceptor);
License
Copyright © 2017 Yisrael Eliav, Licensed under the MIT license.