12 |
- (()=>{"use strict";var e,o={85781:(e,o,s)=>{var n=s(32981),a=s(85471),c=s(56760),r=s(18740),d=s(84237);s(51257);const i={name:"PersonalSettings",components:{NcButton:r.A,NcLoadingIcon:d.A},data:()=>({generatingCodes:!1}),computed:{downloadUrl(){return this.codes?"data:text/plain,"+encodeURIComponent(this.codes.reduce(((e,t)=>e+t+"\r\n"),"")):""},downloadFilename:()=>(OC.theme.name||"Nextcloud")+"-backup-codes.txt",enabled(){return this.$store.state.enabled},total(){return this.$store.state.total},used(){return this.$store.state.used},codes(){return this.$store.state.codes},name:()=>OC.theme.name||"Nextcloud",haveCodes(){return this.codes&&this.codes.length>0}},methods:{generateBackupCodes(){(0,c.C)().then((()=>{this.generatingCodes=!0,this.$store.dispatch("generate").then((()=>{this.generatingCodes=!1})).catch((e=>{throw OC.Notification.showTemporary(t("twofactor_backupcodes","An error occurred while generating your backup codes")),this.generatingCodes=!1,e}))})).catch(console.error.bind(this))},getPrintData:e=>e?e.reduce(((e,t)=>e+t+"<br>"),""):"",printCodes(){!function(e){const o=OC.theme.name||"Nextcloud",s=window.open("",t("twofactor_backupcodes","{name} backup codes",{name:o}));s.document.write("<h1>"+t("twofactor_backupcodes","{name} backup codes",{name:o})+"</h1>"),s.document.write("<pre>"+e+"</pre>"),s.print(),s.close()}(this.getPrintData(this.codes))}}};var u=s(85072),l=s.n(u),p=s(97825),b=s.n(p),f=s(77659),h=s.n(f),g=s(55056),_=s.n(g),A=s(10540),v=s.n(A),m=s(41113),k=s.n(m),C=s(40097),w={};w.styleTagTransform=k(),w.setAttributes=_(),w.insert=h().bind(null,"head"),w.domAPI=b(),w.insertStyleElement=v(),l()(C.A,w),C.A&&C.A.locals&&C.A.locals;const y=(0,s(14486).A)(i,(function(){var e=this,t=e._self._c;return t("div",{staticClass:"backupcodes-settings"},[e.enabled?[t("p",{staticClass:"backupcodes-settings__codes"},[e.haveCodes?[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","These are your backup codes. Please save and/or print them as you will not be able to read the codes again later."))+"\n\t\t\t\t"),t("ul",e._l(e.codes,(function(o){return t("li",{key:o,staticClass:"backupcodes-settings__codes__code"},[e._v("\n\t\t\t\t\t\t"+e._s(o)+"\n\t\t\t\t\t")])})),0)]:[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Backup codes have been generated. {used} of {total} codes have been used.",{used:e.used,total:e.total}))+"\n\t\t\t")]],2),e._v(" "),t("p",{staticClass:"backupcodes-settings__actions"},[e.haveCodes?[t("NcButton",{attrs:{href:e.downloadUrl,download:e.downloadFilename,type:"primary"}},[e._v("\n\t\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Save backup codes"))+"\n\t\t\t\t")]),e._v(" "),t("NcButton",{on:{click:e.printCodes}},[e._v("\n\t\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Print backup codes"))+"\n\t\t\t\t")])]:e._e(),e._v(" "),t("NcButton",{attrs:{id:"generate-backup-codes"},on:{click:e.generateBackupCodes}},[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Regenerate backup codes"))+"\n\t\t\t")])],2),e._v(" "),t("p",[t("em",[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","If you regenerate backup codes, you automatically invalidate old codes."))+"\n\t\t\t")])])]:t("NcButton",{attrs:{id:"generate-backup-codes",disabled:e.generatingCodes},on:{click:e.generateBackupCodes},scopedSlots:e._u([{key:"icon",fn:function(){return[e.generatingCodes?t("NcLoadingIcon"):e._e()]},proxy:!0}],null,!1,4108280908)},[e._v("\n\t\t"+e._s(e.t("twofactor_backupcodes","Generate backup codes"))+"\n\t")])],2)}),[],!1,null,"70ee3f3c",null).exports;var x=s(95353),O=s(65043),B=s(63814);a.Ay.use(x.Ay);const P={setEnabled(e,t){a.Ay.set(e,"enabled",t)},setTotal(e,t){a.Ay.set(e,"total",t)},setUsed(e,t){a.Ay.set(e,"used",t)},setCodes(e,t){a.Ay.set(e,"codes",t)}},N={generate(e){let{commit:t}=e;return t("setEnabled",!1),function(){const e=(0,B.Jv)("/apps/twofactor_backupcodes/settings/create");return O.Ay.post(e,{}).then((e=>e.data))}().then((e=>{let{codes:o,state:s}=e;return t("setEnabled",s.enabled),t("setTotal",s.total),t("setUsed",s.used),t("setCodes",o),!0}))}},S=new x.il({strict:!1,state:{enabled:!1,total:0,used:0,codes:[]},mutations:P,actions:N});a.Ay.prototype.t=t;const T=(0,n.C)("twofactor_backupcodes","state");S.replaceState(T),new(a.Ay.extend(y))({store:S}).$mount("#twofactor-backupcodes-settings")},40097:(e,t,o)=>{o.d(t,{A:()=>r});var s=o(71354),n=o.n(s),a=o(76314),c=o.n(a)()(n());c.push([e.id,".backupcodes-settings__codes__code[data-v-70ee3f3c]{font-family:monospace;letter-spacing:.02em;font-size:1.2em}.backupcodes-settings__actions[data-v-70ee3f3c]{display:flex;flex-wrap:wrap;align-items:center;gap:var(--default-grid-baseline)}","",{version:3,sources:["webpack://./apps/twofactor_backupcodes/src/views/PersonalSettings.vue"],names:[],mappings:"AAGE,oDACC,qBAAA,CACA,oBAAA,CACA,eAAA,CAIF,gDACC,YAAA,CACA,cAAA,CACA,kBAAA,CACA,gCAAA",sourceRoot:""}]);const r=c}},s={};function n(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={id:e,loaded:!1,exports:{}};return o[e].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}n.m=o,e=[],n.O=(t,o,s,a)=>{if(!o){var c=1/0;for(u=0;u<e.length;u++){o=e[u][0],s=e[u][1],a=e[u][2];for(var r=!0,d=0;d<o.length;d++)(!1&a||c>=a)&&Object.keys(n.O).every((e=>n.O[e](o[d])))?o.splice(d--,1):(r=!1,a<c&&(c=a));if(r){e.splice(u--,1);var i=s();void 0!==i&&(t=i)}}return t}a=a||0;for(var u=e.length;u>0&&e[u-1][2]>a;u--)e[u]=e[u-1];e[u]=[o,s,a]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.e=()=>Promise.resolve(),n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n.j=4423,(()=>{n.b=document.baseURI||self.location.href;var e={4423:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var s,a,c=o[0],r=o[1],d=o[2],i=0;if(c.some((t=>0!==e[t]))){for(s in r)n.o(r,s)&&(n.m[s]=r[s]);if(d)var u=d(n)}for(t&&t(o);i<c.length;i++)a=c[i],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return n.O(u)},o=self.webpackChunknextcloud=self.webpackChunknextcloud||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})(),n.nc=void 0;var a=n.O(void 0,[4208],(()=>n(85781)));a=n.O(a)})();
- //# sourceMappingURL=twofactor_backupcodes-settings.js.map?v=96a29b343a0f9d9c9208
|