twofactor_backupcodes-settings.js 6.7 KB

12
  1. (()=>{"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,codes:[]},mutations:N,actions:S});a.Ay.prototype.t=t;const j=(0,s.C)("twofactor_backupcodes","state");T.replaceState(j),new(a.Ay.extend(x))({store:T}).$mount("#twofactor-backupcodes-settings")},40097:(t,e,o)=>{o.d(e,{A:()=>r});var n=o(71354),s=o.n(n),a=o(76314),c=o.n(a)()(s());c.push([t.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",sourcesContent:["\n.backupcodes-settings {\n\t&__codes {\n\t\t&__code {\n\t\t\tfont-family: monospace;\n\t\t\tletter-spacing: 0.02em;\n\t\t\tfont-size: 1.2em;\n\t\t}\n\t}\n\n\t&__actions {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tgap: var(--default-grid-baseline);\n\t}\n}\n"],sourceRoot:""}]);const r=c}},n={};function s(t){var e=n[t];if(void 0!==e)return e.exports;var a=n[t]={id:t,loaded:!1,exports:{}};return o[t].call(a.exports,a,a.exports,s),a.loaded=!0,a.exports}s.m=o,e=[],s.O=(t,o,n,a)=>{if(!o){var c=1/0;for(l=0;l<e.length;l++){o=e[l][0],n=e[l][1],a=e[l][2];for(var r=!0,d=0;d<o.length;d++)(!1&a||c>=a)&&Object.keys(s.O).every((t=>s.O[t](o[d])))?o.splice(d--,1):(r=!1,a<c&&(c=a));if(r){e.splice(l--,1);var i=n();void 0!==i&&(t=i)}}return t}a=a||0;for(var l=e.length;l>0&&e[l-1][2]>a;l--)e[l]=e[l-1];e[l]=[o,n,a]},s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.e=()=>Promise.resolve(),s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),s.j=4423,(()=>{s.b=document.baseURI||self.location.href;var t={4423:0};s.O.j=e=>0===t[e];var e=(e,o)=>{var n,a,c=o[0],r=o[1],d=o[2],i=0;if(c.some((e=>0!==t[e]))){for(n in r)s.o(r,n)&&(s.m[n]=r[n]);if(d)var l=d(s)}for(e&&e(o);i<c.length;i++)a=c[i],s.o(t,a)&&t[a]&&t[a][0](),t[a]=0;return s.O(l)},o=self.webpackChunknextcloud=self.webpackChunknextcloud||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),s.nc=void 0;var a=s.O(void 0,[4208],(()=>s(85781)));a=s.O(a)})();
  2. //# sourceMappingURL=twofactor_backupcodes-settings.js.map?v=ea45701c4a3809f5d4a0