-
Notifications
You must be signed in to change notification settings - Fork 0
/
806.c340d606be3bc18799e4.js
1 lines (1 loc) · 3.42 KB
/
806.c340d606be3bc18799e4.js
1
"use strict";(self.webpackChunksparkworks_console=self.webpackChunksparkworks_console||[]).push([[806],{7806:function(v,A,s){s.r(A),s.d(A,{amplify_select_mfa_type:function(){return y}});var S=s(8239),g=s(75134),O=s(47289),P=s(88774),c=s.n(P),l=s(65513),m=s(45013),o=s(53799),M=s(82073),f=s(33542),h=s(33754),p=s(84665),d=new m.k("SelectMFAType"),y=function(){function E(u){var t=this;(0,g.Z)(this,E),(0,l.r)(this,u),this.handleSubmit=function(a){return t.verify(a)},this.TOTPSetup=!1,this.selectMessage=null,this.MFAMethod=null,this.isTOTP=!1,this.isNoMFA=!1,this.isSMS=!1,this.loading=!1,this.isToastVisible=!1}return(0,O.Z)(E,[{key:"handleRadioButtonChange",value:function(t){this.TOTPSetup=!1,this.selectMessage=null,this.isNoMFA=!1,this.isTOTP=!1,this.isSMS=!1,this.isToastVisible=!1;var a=t.target,n=a.value,r=a.checked,i=["radio","checkbox"].includes(a.type);n===M.M.SMS&&i&&(this.isSMS=r),n===M.M.TOTP&&i&&(this.isTOTP=r),n===M.M.NOMFA&&i&&(this.isNoMFA=r)}},{key:"verify",value:(u=(0,S.Z)(c().mark(function a(n){var T,i;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n&&n.preventDefault(),d.debug("MFA Type Values",{TOTP:this.isTOTP,SMS:this.isSMS,"No MFA":this.isNoMFA}),this.isTOTP?this.MFAMethod=M.M.TOTP:this.isSMS?this.MFAMethod=M.M.SMS:this.isNoMFA&&(this.MFAMethod=M.M.NOMFA),T=this.authData,f.g&&"function"==typeof f.g.setPreferredMFA){e.next=6;break}throw new Error(p.N);case 6:return this.loading=!0,e.prev=7,e.next=10,f.g.setPreferredMFA(T,this.MFAMethod);case 10:d.debug("Set Preferred MFA Succeeded",e.sent),this.selectMessage="".concat(o.o.get(h.T.SUCCESS_MFA_TYPE)," ").concat(this.MFAMethod),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(7),(i=e.t0.message)===p.e||i===p.f?(this.TOTPSetup=!0,this.selectMessage=o.o.get(h.T.SETUP_TOTP_REQUIRED)):(d.debug("Set Preferred MFA failed",e.t0),this.selectMessage=o.o.get(h.T.UNABLE_TO_SETUP_MFA_AT_THIS_TIME));case 19:return e.prev=19,this.loading=!1,this.isToastVisible=!0,e.finish(19);case 23:case"end":return e.stop()}},a,this,[[7,15,19,23]])})),function(a){return u.apply(this,arguments)})},{key:"contentBuilder",value:function(){var t=this;if(!this.MFATypes||Object.keys(this.MFATypes).length<2)return d.debug(o.o.get(h.T.LESS_THAN_TWO_MFA_VALUES_MESSAGE)),(0,l.h)("div",null,(0,l.h)("a",null,o.o.get(h.T.LESS_THAN_TWO_MFA_VALUES_MESSAGE)));var a=this.MFATypes,n=a.SMS,T=a.TOTP,r=a.Optional;return(0,l.h)("amplify-form-section",{submitButtonText:o.o.get(h.T.SELECT_MFA_TYPE_SUBMIT_BUTTON_TEXT),headerText:o.o.get(h.T.SELECT_MFA_TYPE_HEADER_TEXT),handleSubmit:function(_){return t.handleSubmit(_)},loading:this.loading},n?(0,l.h)("amplify-radio-button",{key:"sms",name:"MFAType",value:"SMS",label:"SMS",handleInputChange:function(_){return t.handleRadioButtonChange(_)}}):null,T?(0,l.h)("amplify-radio-button",{key:"totp",name:"MFAType",value:"TOTP",label:"TOTP",handleInputChange:function(_){return t.handleRadioButtonChange(_)}}):null,r?(0,l.h)("amplify-radio-button",{key:"noMFA",name:"MFAType",value:"NOMFA",label:"No MFA",handleInputChange:function(_){return t.handleRadioButtonChange(_)}}):null)}},{key:"renderToast",value:function(){var t=this;return this.isToastVisible&&this.selectMessage?(0,l.h)("amplify-toast",{message:this.selectMessage,handleClose:function(){t.selectMessage=null,t.isToastVisible=!1}}):null}},{key:"render",value:function(){return(0,l.h)("div",null,this.contentBuilder(),this.TOTPSetup?(0,l.h)("amplify-totp-setup",{user:this.authData}):null,this.renderToast())}}]),E;var u}()}}]);