2 lines
No EOL
30 KiB
JavaScript
2 lines
No EOL
30 KiB
JavaScript
(function(e){function t(t){for(var r,a,s=t[0],c=t[1],u=t[2],l=0,f=[];l<s.length;l++)a=s[l],o[a]&&f.push(o[a][0]),o[a]=0;for(r in c)Object.prototype.hasOwnProperty.call(c,r)&&(e[r]=c[r]);d&&d(t);while(f.length)f.shift()();return i.push.apply(i,u||[]),n()}function n(){for(var e,t=0;t<i.length;t++){for(var n=i[t],r=!0,a=1;a<n.length;a++){var s=n[a];0!==o[s]&&(r=!1)}r&&(i.splice(t--,1),e=c(c.s=n[0]))}return e}var r={},a={app:0},o={app:0},i=[];function s(e){return c.p+"js/"+({about:"about",admin:"admin",account:"account"}[e]||e)+"."+{about:"87b858b5",admin:"7d1f7d59","chunk-69f8d7c8":"64905801",account:"ab92099b","chunk-6fc85424":"541c54e1"}[e]+".js"}function c(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,c),n.l=!0,n.exports}c.e=function(e){var t=[],n={"chunk-69f8d7c8":1,account:1,"chunk-6fc85424":1};a[e]?t.push(a[e]):0!==a[e]&&n[e]&&t.push(a[e]=new Promise(function(t,n){for(var r="css/"+({about:"about",admin:"admin",account:"account"}[e]||e)+"."+{about:"31d6cfe0",admin:"31d6cfe0","chunk-69f8d7c8":"ddb698de",account:"37c464f9","chunk-6fc85424":"a19fdb43"}[e]+".css",o=c.p+r,i=document.getElementsByTagName("link"),s=0;s<i.length;s++){var u=i[s],l=u.getAttribute("data-href")||u.getAttribute("href");if("stylesheet"===u.rel&&(l===r||l===o))return t()}var f=document.getElementsByTagName("style");for(s=0;s<f.length;s++){u=f[s],l=u.getAttribute("data-href");if(l===r||l===o)return t()}var d=document.createElement("link");d.rel="stylesheet",d.type="text/css",d.onload=t,d.onerror=function(t){var r=t&&t.target&&t.target.src||o,i=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");i.request=r,delete a[e],d.parentNode.removeChild(d),n(i)},d.href=o;var p=document.getElementsByTagName("head")[0];p.appendChild(d)}).then(function(){a[e]=0}));var r=o[e];if(0!==r)if(r)t.push(r[2]);else{var i=new Promise(function(t,n){r=o[e]=[t,n]});t.push(r[2]=i);var u,l=document.createElement("script");l.charset="utf-8",l.timeout=120,c.nc&&l.setAttribute("nonce",c.nc),l.src=s(e),u=function(t){l.onerror=l.onload=null,clearTimeout(f);var n=o[e];if(0!==n){if(n){var r=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src,i=new Error("Loading chunk "+e+" failed.\n("+r+": "+a+")");i.type=r,i.request=a,n[1](i)}o[e]=void 0}};var f=setTimeout(function(){u({type:"timeout",target:l})},12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},c.m=e,c.c=r,c.d=function(e,t,n){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},c.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(c.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)c.d(n,r,function(t){return e[t]}.bind(null,r));return n},c.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="/",c.oe=function(e){throw console.error(e),e};var u=window["webpackJsonp"]=window["webpackJsonp"]||[],l=u.push.bind(u);u.push=t,u=u.slice();for(var f=0;f<u.length;f++)t(u[f]);var d=l;i.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},"41cb":function(e,t,n){"use strict";var r=n("2b0e"),a=n("8c4f"),o=n("4360"),i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("HelloWorld")},s=[],c=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("v-container",{staticClass:"body-2 ma-4 pa-4",attrs:{"justify-center":"","text-xs-center":""}},[n("div",[n("h1",{staticClass:"display-2 font-weight-bold mb-3"},[e._v("GoBase Demo Application")]),n("p",{staticClass:"subheading font-weight-regular"},[n("a",{attrs:{href:"https://github.com/dhax/go-base",target:"_blank",rel:"noopener"}},[e._v("Check out on GitHub")])])]),n("v-divider"),n("div",{staticClass:"ma-4 pa-4"},[n("h5",{staticClass:"headline"},[e._v("What's this?")]),n("p",[e._v("A Go REST API and Vue.js client demo using a passwordless authentication flow with Json Web Token (JWT)")]),n("p",[e._v("A registered email address requests and then receives a temporary token to login.")]),n("p",[e._v("On successful login an access and a refresh JWT are saved to this client.")])]),n("v-divider"),n("div",{staticClass:"ma-4 pa-4"},[n("h5",{staticClass:"headline"},[e._v("Available Logins")]),n("p",[e._v("For these two emails grab the login token from console output.")]),n("p",[e._v("admin@boot.io (admin panel)")]),n("p",[e._v("user@boot.io (own account)")]),n("p",[e._v("Other registered addresses will recieve an email with login token.")])]),n("v-divider"),n("div",{staticClass:"ma-4 pa-4"},[n("p",[e._v("Database is reset every 24 hours in this demo.")])])],1)},u=[],l=n("2877"),f=n("6544"),d=n.n(f),p=n("a523"),h=n("ce7e6"),v={},m=Object(l["a"])(v,c,u,!1,null,null,null);m.options.__file="HelloWorld.vue";var g=m.exports;d()(m,{VContainer:p["a"],VDivider:h["a"]});var b={components:{HelloWorld:g}},k=b,_=Object(l["a"])(k,i,s,!1,null,null,null);_.options.__file="Home.vue";var T=_.exports,w=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("v-container",{attrs:{fluid:"","fill-height":""}},[n("v-layout",{attrs:{"align-center":"","justify-center":""}},[n("v-flex",{attrs:{xs12:"",sm8:"",md4:""}},[n("v-alert",{staticClass:"elevation-12 text-uppercase",attrs:{value:e.alert.msg,type:e.alert.type,dismissible:"",transition:"scale-transition"}},[e._v(e._s(e.alert.msg))]),n("v-card",{staticClass:"elevation-12"},[n("v-toolbar",{staticClass:"elevation-4"},[n("v-toolbar-title",[e._v("Login")]),n("v-spacer"),n("v-spacer"),n("v-tooltip",{attrs:{top:"","nudge-top":""}},[n("v-btn",{attrs:{slot:"activator",icon:""},on:{click:function(t){e.help=!e.help}},slot:"activator"},[n("v-icon",[e._v("help")])],1),n("span",[e._v("Help")])],1)],1),n("v-slide-y-transition",[n("v-card",{directives:[{name:"show",rawName:"v-show",value:e.help,expression:"help"}],attrs:{dark:""}},[n("v-card-text",[n("p",{staticClass:"body-2 text-xs-center"},[e._v("Submit your email to receive a login token.")]),n("p",{staticClass:"body-2 text-xs-center"},[e._v("Enter received token here to login.")])])],1)],1),n("v-card-text",[n("v-form",{ref:"loginForm",on:{submit:function(t){return t.preventDefault(),e.submit(t)}},model:{value:e.valid,callback:function(t){e.valid=t},expression:"valid"}},[n("v-text-field",{attrs:{name:"input",rules:e.inputRules,label:"Email or Token",required:"",autofocus:""},model:{value:e.input,callback:function(t){e.input=t},expression:"input"}})],1)],1),n("v-card-actions",[n("v-spacer"),n("v-btn",{staticClass:"elevation-12",attrs:{name:"submit",color:"primary",disabled:!e.valid||e.authenticating,loading:e.authenticating},on:{click:e.submit}},[e._v("Submit")])],1)],1)],1)],1)],1)},E=[],R=n("cebc"),O=n("2f62"),x=n("63e0"),j={name:"login",data:function(){var e=this;return{help:!1,valid:!1,input:"",inputRules:[function(e){return!!e||"required"},function(){return e.isEmail||e.isToken||""}]}},computed:Object(R["a"])({},Object(O["c"])(["authenticating","authenticationStatus","authenticationError","authenticationErrorCode"]),{isEmail:function(){return/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(this.input)},isToken:function(){return this.input&&8==this.input.length&&!/@/.test(this.input)},alert:function(){return{msg:this.authenticationError||this.authenticationStatus,type:this.authenticationError?"error":"info"}}}),methods:Object(R["a"])({},Object(O["b"])([x["h"],x["c"]]),{submit:function(){console.log("send token"),this.$refs.loginForm.validate()&&(this.isEmail&&this.AUTH_TOKEN_REQUEST(this.input),this.isToken&&this.AUTH_LOGIN_REQUEST(this.input),this.clearForm())},clearForm:function(){this.$refs.loginForm.reset()}}),mounted:function(){var e=this,t=this.$route.params.token;t&&(this.input=t,setTimeout(function(){e.submit()},300))}},C=j,y=(n("7fa3"),n("0798")),S=n("8336"),A=n("b0af"),U=n("99d9"),V=n("0e8f"),H=n("4bd4"),I=n("132d"),P=n("a722"),L=n("0789"),q=n("9910"),N=n("2677"),B=n("71d9"),D=n("2a7f"),M=n("3a2f"),F=Object(l["a"])(C,w,E,!1,null,null,null);F.options.__file="Login.vue";var $=F.exports;d()(F,{VAlert:y["a"],VBtn:S["a"],VCard:A["a"],VCardActions:U["a"],VCardText:U["b"],VContainer:p["a"],VFlex:V["a"],VForm:H["a"],VIcon:I["a"],VLayout:P["a"],VSlideYTransition:L["e"],VSpacer:q["a"],VTextField:N["a"],VToolbar:B["a"],VToolbarTitle:D["b"],VTooltip:M["a"]}),r["a"].use(a["a"]);var G=function(e,t,n){o["a"].getters.loggedIn?n(!1):n()},Q=function(e,t,n){o["a"].getters["hasRole"]("admin")?n():n(!1)},W=new a["a"]({mode:"history",base:"/",routes:[{path:"/",name:"home",component:T,meta:{public:!0}},{path:"/about",name:"about",meta:{public:!0},component:function(){return n.e("about").then(n.bind(null,"f820"))}},{path:"/login/:token",component:$,meta:{public:!0}},{path:"/login",name:"login",component:$,meta:{public:!0},beforeEnter:G},{path:"/account",name:"account",component:function(){return Promise.all([n.e("chunk-69f8d7c8"),n.e("account")]).then(n.bind(null,"77be"))}},{path:"/admin",beforeEnter:Q,component:function(){return n.e("admin").then(n.bind(null,"3530"))},children:[{path:"accounts",component:function(){return Promise.all([n.e("chunk-69f8d7c8"),n.e("chunk-6fc85424")]).then(n.bind(null,"8c88"))}}]}]});W.beforeEach(function(e,t,n){var r=e.matched.some(function(e){return e.meta.public}),a=o["a"].getters.loggedIn;if(!r&&!a)return n({path:"/login",query:{redirect:e.fullPath}});n()});t["a"]=W},4360:function(e,t,n){"use strict";var r,a,o,i=n("2b0e"),s=n("2f62"),c=n("bd86"),u=(n("96cf"),n("3b8d")),l=(n("7f7f"),n("d225")),f=n("308d"),d=n("6bb5"),p=n("4e2b"),h=n("f28b"),v=n("c5fa"),m=function(e){function t(e,n,r){var a;return Object(l["a"])(this,t),a=Object(f["a"])(this,Object(d["a"])(t).call(this,n)),a.name=a.constructor.name,a.message=n,a.errorCode=e,a.errorFields=r,a}return Object(p["a"])(t,e),t}(Object(h["a"])(Error)),g={getProfile:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,v["a"].get("/api/profile");case 3:return t=e.sent,e.abrupt("return",t.data);case 7:throw e.prev=7,e.t0=e["catch"](0),new m(e.t0.response.status,e.t0.response.data.error,e.t0.response.data.errors);case 10:case"end":return e.stop()}},e,this,[[0,7]])}));function t(){return e.apply(this,arguments)}return t}()},b=n("63e0"),k={status:"",profile:{}},_={getProfile:function(e){return e.profile},isProfileLoaded:function(e){return!!e.profile}},T=Object(c["a"])({},b["k"],function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return n=t.commit,console.log("dispatch USER REQUEST"),n(b["k"]),e.prev=3,e.next=6,g.getProfile();case 6:r=e.sent,n(b["l"],r),e.next=14;break;case 10:return e.prev=10,e.t0=e["catch"](3),e.t0 instanceof m&&n(b["j"],{errorCode:e.t0.errorCode,errorMessage:e.t0.message}),e.abrupt("return",!1);case 14:case"end":return e.stop()}},e,this,[[3,10]])}));return function(t){return e.apply(this,arguments)}}()),w=(r={},Object(c["a"])(r,b["k"],function(e){console.log("USER REQUEST"),e.status="loading"}),Object(c["a"])(r,b["l"],function(e,t){console.log("USER_SUCCESS"),e.profile=t}),Object(c["a"])(r,b["j"],function(e,t){var n=t.errorCode,r=t.errorMessage;console.log("USER_ERROR"),e.errorCode=n,e.errorMessage=r}),r),E={state:k,getters:_,actions:T,mutations:w},R=(n("a481"),n("28a5"),n("673e"),n("6762"),n("2fdb"),n("cadf"),n("551c"),n("097d"),n("f6ed")),O=function(e){function t(e,n){var r;return Object(l["a"])(this,t),r=Object(f["a"])(this,Object(d["a"])(t).call(this,n)),r.name=r.constructor.name,r.message=n,r.errorCode=e,r}return Object(p["a"])(t,e),t}(Object(h["a"])(Error)),x={requestEmailToken:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return n={method:"post",url:"auth/login",data:{grant_type:"email",email:t}},e.prev=1,e.next=4,v["a"].customRequest(n);case 4:return r=e.sent,console.log(r.data),e.abrupt("return",r.data);case 9:throw e.prev=9,e.t0=e["catch"](1),new O(e.t0.response.status,e.t0.response.data.error);case 12:case"end":return e.stop()}},e,this,[[1,9]])}));function t(t){return e.apply(this,arguments)}return t}(),requestJWT:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return n={method:"post",url:"auth/token",data:{grant_type:"token",token:t}},e.prev=1,e.next=4,v["a"].customRequest(n);case 4:return r=e.sent,R["a"].saveToken(r.data.access_token),R["a"].saveRefreshToken(r.data.refresh_token),v["a"].setHeader(),v["a"].mount401Interceptor(),e.abrupt("return",r.data);case 12:throw e.prev=12,e.t0=e["catch"](1),new O(e.t0.response.status,e.t0.response.data.error);case 15:case"end":return e.stop()}},e,this,[[1,12]])}));function t(t){return e.apply(this,arguments)}return t}(),refreshToken:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return t={method:"post",url:"auth/refresh",data:{grant_type:"refresh"}},e.prev=1,v["a"].setRefreshHeader(),e.next=5,v["a"].customRequest(t);case 5:return n=e.sent,R["a"].saveToken(n.data.access_token),R["a"].saveRefreshToken(n.data.refresh_token),v["a"].setHeader(),e.abrupt("return",n.data);case 12:throw e.prev=12,e.t0=e["catch"](1),new O(e.t0.response.status,e.t0.response.data.error);case 15:case"end":return e.stop()}},e,this,[[1,12]])}));function t(){return e.apply(this,arguments)}return t}(),logout:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,t={method:"post",url:"auth/logout",headers:{Authorization:"Bearer ".concat(R["a"].getRefreshToken())}},v["a"].setRefreshHeader(),e.next=5,v["a"].customRequest(t);case 5:e.next=10;break;case 7:throw e.prev=7,e.t0=e["catch"](0),new O(e.t0.response.status,e.t0.response.data.error);case 10:return e.prev=10,v["a"].unmount401Interceptor(),v["a"].removeHeader(),R["a"].removeToken(),R["a"].removeRefreshToken(),e.finish(10);case 16:case"end":return e.stop()}},e,this,[[0,7,10,16]])}));function t(){return e.apply(this,arguments)}return t}(),getAccount:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,v["a"].getAccount();case 3:return t=e.sent,e.abrupt("return",t.data);case 7:throw e.prev=7,e.t0=e["catch"](0),new O(e.t0.response.status,e.t0.response.data.error);case 10:case"end":return e.stop()}},e,this,[[0,7]])}));function t(){return e.apply(this,arguments)}return t}()},j=n("41cb"),C={authenticating:!1,accessToken:R["a"].getToken(),refreshToken:R["a"].getRefreshToken(),authenticationErrorCode:0,authenticationError:"",tokenRequestEmail:"",subject:"",roles:[]},y={loggedIn:function(e){return!!e.accessToken},subject:function(e){return e.subject},roles:function(e){return e.roles},hasRole:function(e){return function(t){return e.roles.includes(t)}},authenticationStatus:function(e){return e.tokenRequestEmail?"Token sent to "+e.tokenRequestEmail:""},authenticationErrorCode:function(e){return e.authenticationErrorCode},authenticationError:function(e){return e.authenticationError},authenticating:function(e){return e.authenticating},localTokenID:function(e){return V(e.refreshToken).id}},S=(a={},Object(c["a"])(a,b["b"],function(e){var t=e.commit,n=e.state,r=e.dispatch;console.log("AUTH_INIT"),n.accessToken&&n.refreshToken&&(I(n.accessToken)?I(n.refreshToken)?r(b["d"]):r(b["f"]):t(b["g"],{access_token:n.accessToken,refresh_token:n.refreshToken}))}),Object(c["a"])(a,b["h"],function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t,n){var r;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return r=t.commit,r(b["h"],n),e.prev=2,e.next=5,x.requestEmailToken(n);case 5:r(b["i"],n),e.next=12;break;case 8:return e.prev=8,e.t0=e["catch"](2),e.t0 instanceof O&&r(b["a"],{errorCode:e.t0.errorCode,errorMessage:e.t0.message}),e.abrupt("return",!1);case 12:case"end":return e.stop()}},e,this,[[2,8]])}));return function(t,n){return e.apply(this,arguments)}}()),Object(c["a"])(a,b["c"],function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t,n){var r,a;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return r=t.commit,r(b["c"]),e.prev=2,e.next=5,x.requestJWT(n);case 5:a=e.sent,r(b["g"],a),j["a"].push(j["a"].history.current.query.redirect||"/"),e.next=14;break;case 10:return e.prev=10,e.t0=e["catch"](2),e.t0 instanceof O&&r(b["a"],{errorCode:e.t0.errorCode,errorMessage:e.t0.message}),e.abrupt("return",!1);case 14:case"end":return e.stop()}},e,this,[[2,10]])}));return function(t,n){return e.apply(this,arguments)}}()),Object(c["a"])(a,b["d"],function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:if(n=t.commit,console.log("dispatch AUTH_LOGOUT"),e.prev=2,I(R["a"].getRefreshToken())){e.next=6;break}return e.next=6,x.logout();case 6:e.next=11;break;case 8:e.prev=8,e.t0=e["catch"](2),e.t0 instanceof O&&n(b["e"],{errorCode:e.t0.errorCode,errorMessage:e.t0.message});case 11:return e.prev=11,n(b["d"]),j["a"].push("/"),e.finish(11);case 15:case"end":return e.stop()}},e,this,[[2,8,11,15]])}));return function(t){return e.apply(this,arguments)}}()),Object(c["a"])(a,b["f"],function(e){var t=e.commit,n=e.state;if(console.log("dispatch AUTH_REFRESH"),!n.refreshTokenPromise){var r=x.refreshToken();t("refreshTokenPromise",r),r.then(function(e){t("refreshTokenPromise",null),t(b["g"],e)},function(e){t("refreshTokenPromise",null),t(b["a"],{errorCode:e.errorCode,errorMessage:e.message})})}return n.refreshTokenPromise}),a),A=(o={},Object(c["a"])(o,b["h"],function(e){console.log("AUTH_TOKEN_REQUEST"),e.authenticating=!0,e.authenticationError="",e.authenticationErrorCode=0,e.tokenRequestEmail=""}),Object(c["a"])(o,b["i"],function(e,t){console.log("AUTH_TOKEN_REQUEST_SUCCESS"),e.authenticating=!1,e.authenticationError="",e.authenticationErrorCode=0,e.tokenRequestEmail=t}),Object(c["a"])(o,b["c"],function(e){console.log("AUTH_LOGIN_REQUEST"),e.authenticating=!0,e.authenticationError="",e.authenticationErrorCode=0,e.tokenRequestEmail=""}),Object(c["a"])(o,b["g"],function(e,t){var n=t.access_token,r=t.refresh_token;console.log("AUTH_SUCCESS"),e.accessToken=n,e.refreshToken=r,e.authenticating=!1,e.authenticationError="";var a=V(n);e.subject=a.sub,e.roles=a.roles}),Object(c["a"])(o,b["a"],function(e,t){var n=t.errorCode,r=t.errorMessage;console.log("AUTH_ERROR"),e.authenticating=!1,e.authenticationErrorCode=n,e.authenticationError=r}),Object(c["a"])(o,b["d"],function(e){console.log("AUTH_LOGOUT"),e.authenticationErrorCode="",e.authenticationError="",e.accessToken="",e.refreshToken="",e.subject="",e.roles=[]}),Object(c["a"])(o,b["e"],function(e,t){var n=t.errorCode,r=t.errorMessage;console.log("AUTH_LOGOUT_ERROR"),e.authenticating=!1,e.authenticationErrorCode=n,e.authenticationError=r}),Object(c["a"])(o,"refreshTokenPromise",function(e,t){e.refreshTokenPromise=t}),o),U={namespaced:!1,state:C,getters:y,actions:S,mutations:A},V=function(e){if(!e)return{};var t=e.split("."),n=t[1].replace(/-/g,"+").replace(/_/g,"/");switch(n.length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break}return JSON.parse(decodeURIComponent(atob(n)))},H=function(e){var t=V(e);if("undefined"===typeof t.exp)return null;var n=new Date(0);return n.setUTCSeconds(t.exp),n},I=function(e){var t=H(e);if(null===t)return!0;var n=new Date;return t.valueOf()<=n.valueOf()};i["a"].use(s["a"]);t["a"]=new s["a"].Store({modules:{user:E,auth:U},state:{},mutations:{},actions:{}})},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("097d");var r=n("2b0e"),a=n("bb71");n("da64");r["a"].use(a["a"],{theme:{primary:"#13232B",secondary:"#2B4851",accent:"#B0BEC5",error:"#D6473A",info:"#7799B8",success:"#4CAF50",warning:"#E57436"},customProperties:!0,iconfont:"md"});var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("v-app",{attrs:{id:"inspire"}},[n("v-navigation-drawer",{attrs:{fixed:"",right:"",clipped:"",app:"","disable-resize-watcher":""},model:{value:e.drawerRight,callback:function(t){e.drawerRight=t},expression:"drawerRight"}},[n("v-list",{attrs:{dense:""}},[n("v-list-tile",{on:{click:function(t){t.stopPropagation(),e.right=!e.right}}},[n("v-list-tile-action",[n("v-icon",[e._v("exit_to_app")])],1),n("v-list-tile-content",[n("v-list-tile-title",[e._v("Open Temporary Drawer")])],1)],1)],1)],1),n("v-toolbar",{attrs:{dense:"",color:"primary",dark:"",fixed:"",app:""}},[e.loggedIn?n("v-toolbar-side-icon",{attrs:{name:"menu"},on:{click:function(t){t.stopPropagation(),e.drawer=!e.drawer}}}):e._e(),n("v-toolbar-title",[n("router-link",{attrs:{to:"/"}},[n("v-btn",{attrs:{flat:""}},[e._v("GoBase")])],1)],1),n("v-spacer"),n("v-toolbar-items",[n("AuthMenu")],1),e.loggedIn?n("v-toolbar-side-icon",{on:{click:function(t){t.stopPropagation(),e.drawerRight=!e.drawerRight}}}):e._e()],1),n("v-navigation-drawer",{attrs:{fixed:"",app:""},model:{value:e.drawer,callback:function(t){e.drawer=t},expression:"drawer"}},[n("v-list",{attrs:{dense:""}},[n("v-list-tile",{on:{click:function(t){t.stopPropagation(),e.left=!e.left}}},[n("v-list-tile-action",[n("v-icon",[e._v("exit_to_app")])],1),n("v-list-tile-content",[n("v-list-tile-title",[e._v("Open Temporary Drawer")])],1)],1)],1),e.hasRole("admin")?n("v-list",{staticClass:"subheader"},[n("v-divider"),n("v-subheader",[e._v("Admin Panel")]),n("v-list-tile",{attrs:{to:"/admin/accounts",name:"accounts"}},[n("v-list-tile-action",[n("v-icon",[e._v("security")])],1),n("v-list-tile-content",[n("v-list-tile-title",[e._v("Accounts")])],1)],1)],1):e._e()],1),n("v-navigation-drawer",{attrs:{temporary:"",fixed:""},model:{value:e.left,callback:function(t){e.left=t},expression:"left"}}),n("v-content",[n("router-view")],1),n("v-navigation-drawer",{attrs:{right:"",temporary:"",fixed:""},model:{value:e.right,callback:function(t){e.right=t},expression:"right"}}),n("v-footer",{staticClass:"black--text pa-4",attrs:{app:""}},[n("span",[e._v("GoBase")]),n("v-spacer"),n("span",[e._v("© 2019")])],1),n("confirm",{ref:"confirm"})],1)},i=[],s=n("cebc"),c=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.loggedIn?n("v-menu",{attrs:{dark:"",left:""}},[n("v-btn",{attrs:{slot:"activator",name:"menuAccount",flat:""},slot:"activator"},[n("v-icon",[e._v("account_box")]),n("v-icon",[e._v("more_vert")])],1),n("v-list",[n("v-list-tile",{staticClass:"elevation-6"},[n("v-list-tile-title",{staticClass:"text-xs-center"},[e._v(e._s(e.subject))])],1),n("v-divider"),n("v-list-tile",[n("v-btn",{staticClass:"text-xs-center",attrs:{name:"account",to:"/account",block:"",light:""}},[n("v-icon",{attrs:{left:""}},[e._v("account_box")]),e._v("Account\n ")],1)],1),n("v-divider"),n("v-list-tile",[n("v-btn",{staticClass:"text-xs-center warning",attrs:{name:"logout",block:""},on:{click:e.logout}},[n("v-icon",{attrs:{left:""}},[e._v("logout")]),e._v("Logout\n ")],1)],1)],1)],1):n("v-btn",{attrs:{slot:"activator",name:"login",to:"/login",flat:""},slot:"activator"},[e._v("Login")])},u=[],l=n("2f62"),f=n("63e0"),d={name:"AuthMenu",computed:Object(s["a"])({},Object(l["c"])(["loggedIn","subject"])),methods:Object(s["a"])({},Object(l["b"])({logout:f["d"]}))},p=d,h=n("2877"),v=n("6544"),m=n.n(v),g=n("8336"),b=n("ce7e6"),k=n("132d"),_=n("8860"),T=n("ba95"),w=n("5d23"),E=n("e449"),R=Object(h["a"])(p,c,u,!1,null,null,null);R.options.__file="AuthMenu.vue";var O=R.exports;m()(R,{VBtn:g["a"],VDivider:b["a"],VIcon:k["a"],VList:_["a"],VListTile:T["a"],VListTileTitle:w["b"],VMenu:E["a"]});var x=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("v-dialog",{style:{zIndex:e.options.zIndex},attrs:{"max-width":e.options.width},on:{keydown:function(t){return"button"in t||!e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?e.cancel(t):null}},model:{value:e.dialog,callback:function(t){e.dialog=t},expression:"dialog"}},[n("v-card",[n("v-toolbar",{attrs:{dark:"",color:e.options.color,dense:"",flat:""}},[n("v-toolbar-title",{staticClass:"white--text"},[e._v(e._s(e.title))])],1),n("v-card-text",{directives:[{name:"show",rawName:"v-show",value:!!e.message,expression:"!!message"}]},[e._v(e._s(e.message))]),n("v-card-actions",{staticClass:"pt-0"},[n("v-spacer"),n("v-btn",{attrs:{color:"primary darken-1"},nativeOn:{click:function(t){return e.agree(t)}}},[e._v("Yes")]),n("v-btn",{nativeOn:{click:function(t){return e.cancel(t)}}},[e._v("Cancel")])],1)],1)],1)},j=[],C=n("795b"),y=n.n(C),S=n("5176"),A=n.n(S),U={data:function(){return{dialog:!1,resolve:null,reject:null,message:null,title:null,options:{color:"primary",width:290,zIndex:200}}},methods:{open:function(e,t,n){var r=this;return this.dialog=!0,this.title=e,this.message=t,this.options=A()(this.options,n),new y.a(function(e,t){r.resolve=e,r.reject=t})},agree:function(){this.resolve(!0),this.dialog=!1},cancel:function(){this.resolve(!1),this.dialog=!1}}},V=U,H=n("b0af"),I=n("99d9"),P=n("169a"),L=n("9910"),q=n("71d9"),N=n("2a7f"),B=Object(h["a"])(V,x,j,!1,null,null,null);B.options.__file="confirmDialog.vue";var D=B.exports;m()(B,{VBtn:g["a"],VCard:H["a"],VCardActions:I["a"],VCardText:I["b"],VDialog:P["a"],VSpacer:L["a"],VToolbar:q["a"],VToolbarTitle:N["b"]});var M={components:{AuthMenu:O,confirm:D},props:{source:String},data:function(){return{drawer:null,drawerRight:null,right:!1,left:!1}},computed:Object(s["a"])({},Object(l["c"])(["loggedIn","subject","hasRole"])),mounted:function(){this.$root.$confirm=this.$refs.confirm.open}},F=M,$=n("7496"),G=n("549c"),Q=n("553a"),W=n("40fe"),J=n("f774"),z=n("e0c7"),K=n("706c"),Y=Object(h["a"])(F,o,i,!1,null,null,null);Y.options.__file="App.vue";var X=Y.exports;m()(Y,{VApp:$["a"],VBtn:g["a"],VContent:G["a"],VDivider:b["a"],VFooter:Q["a"],VIcon:k["a"],VList:_["a"],VListTile:T["a"],VListTileAction:W["a"],VListTileContent:w["a"],VListTileTitle:w["b"],VNavigationDrawer:J["a"],VSpacer:L["a"],VSubheader:z["a"],VToolbar:q["a"],VToolbarItems:N["a"],VToolbarSideIcon:K["a"],VToolbarTitle:N["b"]});var Z=n("41cb"),ee=n("4360"),te=n("9483");Object(te["a"])("".concat("/","service-worker.js"),{ready:function(){console.log("App is being served from cache by a service worker.\nFor more details, visit https://goo.gl/AFskqB")},cached:function(){console.log("Content has been cached for offline use.")},updated:function(){console.log("New content is available; please refresh.")},offline:function(){console.log("No internet connection found. App is running in offline mode.")},error:function(e){console.error("Error during service worker registration:",e)}});var ne=n("c5fa"),re=n("f6ed");r["a"].config.productionTip=!1,ne["a"].init("https://govue.herokuapp.com/"),re["a"].getToken()&&(ne["a"].setHeader(),ne["a"].mount401Interceptor()),r["a"].filter("formatDate",function(e){var t=new Date(e);return t.toLocaleDateString("en",{year:"numeric",month:"short",day:"2-digit"})}),new r["a"]({router:Z["a"],store:ee["a"],render:function(e){return e(X)}}).$mount("#app")},"63e0":function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"h",function(){return a}),n.d(t,"i",function(){return o}),n.d(t,"c",function(){return i}),n.d(t,"f",function(){return s}),n.d(t,"g",function(){return c}),n.d(t,"a",function(){return u}),n.d(t,"d",function(){return l}),n.d(t,"e",function(){return f}),n.d(t,"k",function(){return d}),n.d(t,"l",function(){return p}),n.d(t,"j",function(){return h});var r="AUTH_INIT",a="AUTH_TOKEN_REQUEST",o="AUTH_TOKEN_REQUEST_SUCCESS",i="AUTH_LOGIN_REQUEST",s="AUTH_REFRESH_REQUEST",c="AUTH_SUCCESS",u="AUTH_ERROR",l="AUTH_LOGOUT",f="AUTH_LOGOUT_ERROR",d="USER_REQUEST",p="USER_SUCCESS",h="USER_ERROR"},"7fa3":function(e,t,n){"use strict";var r=n("f8b5"),a=n.n(r);a.a},c5fa:function(e,t,n){"use strict";n("6762"),n("2fdb"),n("96cf");var r=n("3b8d"),a=(n("cadf"),n("551c"),n("097d"),n("bc3a")),o=n.n(a),i=n("f6ed"),s=n("4360"),c=n("63e0"),u={init:function(e){o.a.defaults.baseURL=e,o.a.defaults.headers.common={Accept:"application/json","Content-Type":"application/json"},s["a"].dispatch(c["b"])},setHeader:function(){o.a.defaults.headers.common["Authorization"]="Bearer ".concat(i["a"].getToken())},setRefreshHeader:function(){o.a.defaults.headers.common["Authorization"]="Bearer ".concat(i["a"].getRefreshToken())},removeHeader:function(){o.a.defaults.headers.common={}},get:function(e,t){return o.a.get(e,{params:t})},post:function(e,t){return o.a.post(e,t)},put:function(e,t){return o.a.put(e,t)},delete:function(e){return o.a.delete(e)},customRequest:function(e){return o()(e)},_401interceptor:null,mount401Interceptor:function(){var e=this;this._401interceptor=o.a.interceptors.response.use(function(e){return e},function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(n){return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:if(401!=n.request.status){t.next=15;break}if(!n.config.url.includes("/auth/refresh")&&!n.config.url.includes("/auth/logout")){t.next=6;break}throw s["a"].dispatch(c["d"]),n;case 6:return t.prev=6,t.next=9,s["a"].dispatch(c["f"]);case 9:return t.abrupt("return",e.customRequest({method:n.config.method,url:n.config.url,data:n.config.data}));case 12:throw t.prev=12,t.t0=t["catch"](6),n;case 15:throw n;case 16:case"end":return t.stop()}},t,this,[[6,12]])}));return function(e){return t.apply(this,arguments)}}())},unmount401Interceptor:function(){o.a.interceptors.response.eject(this._401interceptor)}};t["a"]=u},f6ed:function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r="access_token",a="refresh_token",o={getToken:function(){return localStorage.getItem(r)},saveToken:function(e){localStorage.setItem(r,e)},removeToken:function(){localStorage.removeItem(r)},getRefreshToken:function(){return localStorage.getItem(a)},saveRefreshToken:function(e){localStorage.setItem(a,e)},removeRefreshToken:function(){localStorage.removeItem(a)}}},f8b5:function(e,t,n){}});
|
|
//# sourceMappingURL=app.7d3aa2f3.js.map
|