"use strict";(self["webpackChunkModoboa"]=self["webpackChunkModoboa"]||[]).push([[360],{3602:function(e,t,o){o.r(t),o.d(t,{default:function(){return B}});var s=o(6313),a=o(7953),r=function(){var e=this,t=e._self._c;return t("div",[t(s.Z,{attrs:{flat:""}},[t(a.qW,[t("translate",[e._v("Security")])],1)],1),t("div",{staticClass:"pa-4"},[t("two-factor-auth-form",{attrs:{account:e.authUser}})],1)],1)},n=[],c=o(629),i=o(3694),l=o(4562),u=o(4145),d=o(4886),h=o(266),p=o(4061),f=o(1713),v=o(7808),y=function(){var e=this,t=e._self._c;return t("div",[t(u.Z,{attrs:{flat:""}},[t(d.EB,[t("span",{staticClass:"text-subtitle-1"},[t("translate",[e._v("Two factor authentication")])],1)]),t(d.ZB,[e.qrCode?[t(f.Z,[t(h.Z,{attrs:{cols:"4"}},[t("div",{domProps:{innerHTML:e._s(e.qrCode)}})]),t(h.Z,{attrs:{cols:"6"}},[t(i.Z,{attrs:{type:"info"}},[t("translate",[e._v(" Install a soft token authenticator like FreeOTP or Google Authenticator from your application repository and use that app to scan this QR code. ")])],1),t("label",{staticClass:"m-label"},[t("translate",[e._v("Pin code")])],1),t("validation-observer",{ref:"observer"},[t("validation-provider",{attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function({errors:o}){return[t(v.Z,{attrs:{outlined:"","error-messages":o},model:{value:e.pinCode,callback:function(t){e.pinCode=t},expression:"pinCode"}})]}}],null,!1,1253383749)})],1),t(l.Z,{attrs:{color:"primary"},on:{click:e.finalizeTFASetup}},[t("translate",[e._v("Register")])],1)],1)],1)]:e.tokens.length?[t(i.Z,{attrs:{type:"success"}},[t("translate",[e._v(" Congratulations! Two-Factor Authentication is now enabled for your account. ")])],1),t("p",[t("translate",[e._v(" The following recovery codes can be used one time each to let you regain access to your account, in case you lose your phone for example. Make sure to save them in a safe place, otherwise you won't be able to access your account anymore. ")])],1),t("ul",e._l(e.tokens,(function(o){return t("li",{key:o},[e._v(" "+e._s(o)+" ")])})),0)]:e.account.tfa_enabled?[t(i.Z,{attrs:{type:"info"}},[e._v(" Two-Factor Authentication is enabled for your account. ")]),t(l.Z,{staticClass:"mr-2",attrs:{color:"error"},on:{click:e.disableTFA}},[t("translate",[e._v("Disable 2FA")])],1),t(l.Z,{on:{click:e.resetRecoveryCodes}},[t("translate",[e._v("Reset recovery codes")])],1)]:[t("translate",{staticClass:"my-4",attrs:{tag:"p"}},[e._v(" Two-Factor Authentication (2FA) is not yet activated for your account. Enabling this feature will increase your account's security. ")]),t(l.Z,{attrs:{color:"success"},on:{click:e.startTFASetup}},[t("translate",[e._v("Enable 2FA")])],1)]],2)],1),t(p.Z,{attrs:{"max-width":"800px",persistent:""},model:{value:e.showCodesResetDialog,callback:function(t){e.showCodesResetDialog=t},expression:"showCodesResetDialog"}},[t("recovery-codes-reset-dialog",{attrs:{tokens:e.newTokens},on:{close:e.closeRecoveryCodesResetDialog}})],1)],1)},C=[],k=o(2257),_=o(6808),b=o.n(_),w=o(3687),m=function(){var e=this,t=e._self._c;return t(u.Z,[t(d.EB,[t("span",{staticClass:"headline"},[t("translate",[e._v("New recovery codes")])],1)]),t(d.ZB,[t(i.Z,{attrs:{type:"info"}},[t("translate",[e._v(" The following recovery codes can be used one time each to let you regain access to your account, in case you lose your phone for example. Make sure to save them in a safe place, otherwise you won't be able to access your account anymore. ")])],1),t("ul",e._l(e.tokens,(function(o){return t("li",{key:o},[e._v(" "+e._s(o)+" ")])})),0)],1),t(d.h7,[t(w.Z),t(l.Z,{attrs:{color:"grey darken-1",text:""},on:{click:e.close}},[t("translate",[e._v("Close")])],1)],1)],1)},Z=[],g={props:{tokens:Array},methods:{close(){this.$emit("close")}}},T=g,R=o(1001),F=(0,R.Z)(T,m,Z,!1,null,null,null),A=F.exports,S={components:{RecoveryCodesResetDialog:A},props:{account:Object},data(){return{newTokens:[],pinCode:null,qrCode:null,showCodesResetDialog:!1,tokens:[]}},methods:{getQRCode(){k.Z.getQRCodeForTFASetup().then((e=>{this.qrCode=e.data}))},startTFASetup(){k.Z.startTFASetup().then((e=>{this.getQRCode()}))},async finalizeTFASetup(){const e=await this.$refs.observer.validate();if(!e)return;const t=await k.Z.finalizeTFASetup(this.pinCode);this.qrCode=null,this.tokens=t.data.tokens,b().set("token",t.data.access,{sameSite:"strict"}),b().set("refreshToken",t.data.refresh,{sameSite:"strict"}),this.$store.dispatch("auth/initialize")},disableTFA(){k.Z.disableTFA().then((e=>{this.$store.dispatch("auth/fetchUser")}))},resetRecoveryCodes(){k.Z.resetRecoveryCodes().then((e=>{this.newTokens=e.data.tokens,this.showCodesResetDialog=!0}))},closeRecoveryCodesResetDialog(){this.newTokens=[],this.showCodesResetDialog=!1}},created(){this.account.tfa_enabled||this.getQRCode()}},x=S,D=(0,R.Z)(x,y,C,!1,null,null,null),q=D.exports,M={components:{TwoFactorAuthForm:q},computed:{...(0,c.Se)({authUser:"auth/authUser"})}},Q=M,z=(0,R.Z)(Q,r,n,!1,null,"0fae9bfc",null),B=z.exports}}]);
//# sourceMappingURL=360.dee71d76.js.map