2019-09-19 07:19:11 +00:00
|
|
|
{"version":3,"sources":["auth.js"],"names":["const","lsKeys","token","page","localStorage","user","pass","unhide","document","querySelector","classList","add","remove","onAxiosError","error","console","statusText","520","521","522","523","524","525","526","527","530","response","status","description","data","swal","do","dest","trigger","value","trim","axios","post","username","password","then","success","window","location","catch","verify","onload","form","addEventListener","event","preventDefault","checkValidity","currentTarget"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,SAGHC,KAAO,CAEXD,MAAOE,aAAaH,OAAOC,OAG3BG,KAAM,KACNC,KAAM,KAGRC,OAAW,WACTC,SAASC,cAAc,WAAWC,UAAUC,IAAI,aAChDH,SAASC,cAAc,UAAUC,UAAUE,OAAO,cAIpDC,aAAiB,SAAGC,GAClBC,QAAQD,MAAMA,GAGdd,IAYMgB,EAZmB,CACvBC,IAAK,gBACLC,IAAK,qBACLC,IAAK,uBACLC,IAAK,wBACLC,IAAK,qBACLC,IAAK,uBACLC,IAAK,0BACLC,IAAK,gBACLC,IAAK,oBAG6BX,EAAMY,SAASC,SAAWb,EAAMY,SAASV,WACvEY,EAAcd,EAAMY,SAASG,MAAQf,EAAMY,SAASG,KAAKD,YAC3Dd,EAAMY,SAASG,KAAKD,YACpB,sFAEJ,OAAOE,KAAQhB,EAAMY,SAAS,OAAM,IAAIV,EAAcY,EAAa,UAGrEG,GAAO,SAAIC,EAAMC,GACfjC,IAAMK,EAAOF,KAAKE,KAAK6B,MAAMC,OAC7B,IAAK9B,EACH,OAAOyB,KAAK,qBAAsB,kCAAmC,SAEvE9B,IAAMM,EAAOH,KAAKG,KAAK4B,MAAMC,OAC7B,IAAK7B,EACH,OAAOwB,KAAK,qBAAsB,kCAAmC,SAEvEG,EAAQvB,UAAUC,IAAI,cACtByB,MAAMC,KAAK,OAAOL,EAAQ,CACxBM,SAAUjC,EACVkC,SAAUjC,IACTkC,MAAI,SAACd,GACN,IAA8B,IAA1BA,EAASG,KAAKY,QAEhB,OADAR,EAAQvB,UAAUE,OAAO,cAClBkB,KAAK,aAAaE,EAAI,IAAKN,EAASG,KAAKD,YAAa,SAG/DxB,aAAaF,MAAQwB,EAASG,KAAK3B,MACnCwC,OAAOC,SAAW,eACjBC,OAAK,SAAC9B,GACPmB,EAAQvB,UAAUE,OAAO,cACzBT,KAAKU,aAAaC,OAItB+B,OAAW,WACTT,MAAMC,KAAK,oBAAqB,CAC9BnC,MAAOC,KAAKD,QACXsC,MAAI,SAACd,GACN,IAA8B,IAA1BA,EAASG,KAAKY,QAEhB,OADAtC,KAAKI,SACEuB,KAAK,qBAAsBJ,EAASG,KAAKD,YAAa,SAI/Dc,OAAOC,SAAW,eACjBC,OAAK,SAAC9B,GACPX,KAAKI,SACLJ,KAAKU,aAAaC,QAItB4B,OAAOI,OAAM,WACX3C,KAAKE,KAAOG,SAASC,cAAc,SACnCN,KAAKG,KAAOE,SAASC,cAAc,SAGnCT,IAAM+C,EAAOvC,SAASC,cAAc,aACpCsC,EAAKC,iBAAiB,UAAQ,SAAEC,GAC9BA,EAAMC,oBAGR1C,SAASC,cAAc,aAAauC,iBAAiB,SAAO,SAAEC,GACvDF,EAAKI,iBACVhD,KAAK4B,GAAG,QAASkB,EAAMG,kBAGzB5C,SAASC,cAAc,gBAAgBuC,iBAAiB,SAAO,SAAEC,GAC1DF,EAAKI,iBACVhD,KAAK4B,GAAG,WAAYkB,EAAMG,kBAGxBjD,KAAKD,MACPC,KAAK0C,SAEL1C,KAAKI","file":"auth.js","sourcesContent":["/* global swal, axios */\n\nconst lsKeys = {\n token: 'token'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // HTML elements\n user: null,\n pass: null\n}\n\npage.unhide = () => {\n document.querySelector('#loader').classList.add('is-hidden')\n document.querySelector('#login').classList.remove('is-hidden')\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request, please check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.do = (dest, trigger) => {\n const user = page.user.value.trim()\n if (!user)\n return swal('An error occurred!', 'You need to specify a username.', 'error')\n\n const pass = page.pass.value.trim()\n if (!pass)\n return swal('An error occurred!', 'You need to specify a password.', 'error')\n\n trigger.classList.add('is-loading')\n axios.post(`api/${dest}`, {\n username: user,\n password: pass\n }).then(response => {\n if (response.data.success === false) {\n trigger.classList.remove('is-loading')\n return swal(`Unable to ${dest}!`, response.data.description, 'error')\n }\n\n localStorage.token = response.data.token\n window.location = 'dashboard'\n }
|