UNPKG

@websanova/vue-auth

Version:

A simple light-weight authentication library for Vue.js

63 lines (58 loc) 1.6 kB
/*! * @websanova/vue-auth v4.2.1 * https://websanova.com/docs/vue-auth * Released under the MIT License. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.VueAuth = factory()); }(this, (function () { 'use strict'; var vueResource_1_x = { init: function () { if (!this.plugins.http) { return 'drivers/http/vue-resource.1.x.js: http plugin has not been set.'; } }, interceptor: function (req, res) { var _this = this; this.plugins.http.interceptors.push(function (request, next) { if (req) { req.call(_this, request); } next(function (response) { if (res) { res.call(_this, response, request); } }); }); }, invalidToken: function (res) { if (res.status === 401) { return true; } }, httpData: function (res) { return res.data || {}; }, http: function (data) { return this.plugins.http(data); }, getHeaders: function (res) { var i, data = {}, headers = res.headers.map; for (i in headers) { data[i] = headers[i][0]; } return data; }, setHeaders: function (req, headers) { var i; for (i in headers) { req.headers.set(i, headers[i]); } } }; return vueResource_1_x; })));