UNPKG

@websanova/vue-auth

Version:

A simple light-weight authentication library for Vue.js

7 lines (6 loc) 981 B
/*! * @websanova/vue-auth v4.2.1 * https://websanova.com/docs/vue-auth * Released under the MIT License. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueAuth=e()}(this,function(){"use strict";return{init:function(){if(!this.plugins.http)return"drivers/http/axios.js: http plugin has not been set."},interceptor:function(e,n){var r=this;e&&this.plugins.http.interceptors.request.use(function(t){return e.call(r,t),t},function(t){return e.call(r,t.request),Promise.reject(t)}),n&&this.plugins.http.interceptors.response.use(function(t){return n.call(r,t),t},function(t){return t&&t.response&&n.call(r,t.response),Promise.reject(t)})},invalidToken:function(t){if(401===t.status)return!0},httpData:function(t){return t.data||{}},http:function(t){return this.plugins.http(t)},getHeaders:function(t){return t.headers},setHeaders:function(t,e){t.headers=Object.assign({},t.headers,e)}}});