nextcloud/dist/twofactor_backupcodes-settings.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

2 lines
6.7 KiB
JavaScript
Raw Permalink Normal View History

(()=>{"use strict";var e,o={85781:(e,o,n)=>{var s=n(32981),a=n(85471),c=n(56760),r=n(18740),d=n(84237),i=(n(51257),n(96763));const l={name:"PersonalSettings",components:{NcButton:r.A,NcLoadingIcon:d.A},data:()=>({generatingCodes:!1}),computed:{downloadUrl(){return this.codes?"data:text/plain,"+encodeURIComponent(this.codes.reduce(((t,e)=>t+e+"\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(i.error.bind(this))},getPrintData:t=>t?t.reduce(((t,e)=>t+e+"<br>"),""):"",printCodes(){!function(e){const o=OC.theme.name||"Nextcloud",n=window.open("",t("twofactor_backupcodes","{name} backup codes",{name:o}));n.document.write("<h1>"+t("twofactor_backupcodes","{name} backup codes",{name:o})+"</h1>"),n.document.write("<pre>"+e+"</pre>"),n.print(),n.close()}(this.getPrintData(this.codes))}}};var u=n(85072),p=n.n(u),b=n(97825),f=n.n(b),g=n(77659),h=n.n(g),_=n(55056),v=n.n(_),A=n(10540),m=n.n(A),k=n(41113),C=n.n(k),w=n(40097),y={};y.styleTagTransform=C(),y.setAttributes=v(),y.insert=h().bind(null,"head"),y.domAPI=f(),y.insertStyleElement=m(),p()(w.A,y),w.A&&w.A.locals&&w.A.locals;const x=(0,n(14486).A)(l,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"backupcodes-settings"},[t.enabled?[e("p",{staticClass:"backupcodes-settings__codes"},[t.haveCodes?[t._v("\n\t\t\t\t"+t._s(t.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"),e("ul",t._l(t.codes,(function(o){return e("li",{key:o,staticClass:"backupcodes-settings__codes__code"},[t._v("\n\t\t\t\t\t\t"+t._s(o)+"\n\t\t\t\t\t")])})),0)]:[t._v("\n\t\t\t\t"+t._s(t.t("twofactor_backupcodes","Backup codes have been generated. {used} of {total} codes have been used.",{used:t.used,total:t.total}))+"\n\t\t\t")]],2),t._v(" "),e("p",{staticClass:"backupcodes-settings__actions"},[t.haveCodes?[e("NcButton",{attrs:{href:t.downloadUrl,download:t.downloadFilename,type:"primary"}},[t._v("\n\t\t\t\t\t"+t._s(t.t("twofactor_backupcodes","Save backup codes"))+"\n\t\t\t\t")]),t._v(" "),e("NcButton",{on:{click:t.printCodes}},[t._v("\n\t\t\t\t\t"+t._s(t.t("twofactor_backupcodes","Print backup codes"))+"\n\t\t\t\t")])]:t._e(),t._v(" "),e("NcButton",{attrs:{id:"generate-backup-codes"},on:{click:t.generateBackupCodes}},[t._v("\n\t\t\t\t"+t._s(t.t("twofactor_backupcodes","Regenerate backup codes"))+"\n\t\t\t")])],2),t._v(" "),e("p",[e("em",[t._v("\n\t\t\t\t"+t._s(t.t("twofactor_backupcodes","If you regenerate backup codes, you automatically invalidate old codes."))+"\n\t\t\t")])])]:e("NcButton",{attrs:{id:"generate-backup-codes",disabled:t.generatingCodes},on:{click:t.generateBackupCodes},scopedSlots:t._u([{key:"icon",fn:function(){return[t.generatingCodes?e("NcLoadingIcon"):t._e()]},proxy:!0}],null,!1,4108280908)},[t._v("\n\t\t"+t._s(t.t("twofactor_backupcodes","Generate backup codes"))+"\n\t")])],2)}),[],!1,null,"70ee3f3c",null).exports;var O=n(95353),B=n(65043),P=n(63814);a.Ay.use(O.Ay);const N={setEnabled(t,e){a.Ay.set(t,"enabled",e)},setTotal(t,e){a.Ay.set(t,"total",e)},setUsed(t,e){a.Ay.set(t,"used",e)},setCodes(t,e){a.Ay.set(t,"codes",e)}},S={generate(t){let{commit:e}=t;return e("setEnabled",!1),function(){const t=(0,P.Jv)("/apps/twofactor_backupcodes/settings/create");return B.Ay.post(t,{}).then((t=>t.data))}().then((t=>{let{codes:o,state:n}=t;return e("setEnabled",n.enabled),e("setTotal",n.total),e("setUsed",n.used),e("setCodes",o),!0}))}},T=new O.il({strict:!1,state:{enabled:!1,total:0,used:0,cod
//# sourceMappingURL=twofactor_backupcodes-settings.js.map?v=ea45701c4a3809f5d4a0