UNPKG

@websanova/vue-auth

Version:

A simple light-weight authentication library for Vue.js

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