@@ -1080,7 +1080,12 @@ function closeUserAccount(domainAccountID: number, domain: string, targetEmail:
10801080
10811081function toggleTwoFactorAuthRequiredForDomain ( domainAccountID : number , domainName : string , twoFactorAuthRequired : boolean , twoFactorAuthCode ?: string ) {
10821082 const optimisticData : Array <
1083- OnyxUpdate < typeof ONYXKEYS . COLLECTION . SHARED_NVP_PRIVATE_DOMAIN_MEMBER | typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS | typeof ONYXKEYS . COLLECTION . DOMAIN_ERRORS >
1083+ OnyxUpdate <
1084+ | typeof ONYXKEYS . COLLECTION . SHARED_NVP_PRIVATE_DOMAIN_MEMBER
1085+ | typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS
1086+ | typeof ONYXKEYS . COLLECTION . DOMAIN_ERRORS
1087+ | typeof ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE
1088+ >
10841089 > = [
10851090 {
10861091 onyxMethod : Onyx . METHOD . MERGE ,
@@ -1105,8 +1110,13 @@ function toggleTwoFactorAuthRequiredForDomain(domainAccountID: number, domainNam
11051110 setTwoFactorAuthRequiredError : null ,
11061111 } ,
11071112 } ,
1113+ {
1114+ onyxMethod : Onyx . METHOD . SET ,
1115+ key : ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE ,
1116+ value : null ,
1117+ } ,
11081118 ] ;
1109- const successData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS | typeof ONYXKEYS . COLLECTION . DOMAIN_ERRORS > > = [
1119+ const successData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS | typeof ONYXKEYS . COLLECTION . DOMAIN_ERRORS | typeof ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE > > = [
11101120 {
11111121 onyxMethod : Onyx . METHOD . MERGE ,
11121122 key : `${ ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS } ${ domainAccountID } ` ,
@@ -1121,9 +1131,19 @@ function toggleTwoFactorAuthRequiredForDomain(domainAccountID: number, domainNam
11211131 setTwoFactorAuthRequiredError : null ,
11221132 } ,
11231133 } ,
1134+ {
1135+ onyxMethod : Onyx . METHOD . SET ,
1136+ key : ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE ,
1137+ value : null ,
1138+ } ,
11241139 ] ;
11251140 const failureData : Array <
1126- OnyxUpdate < typeof ONYXKEYS . COLLECTION . SHARED_NVP_PRIVATE_DOMAIN_MEMBER | typeof ONYXKEYS . COLLECTION . DOMAIN_ERRORS | typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS >
1141+ OnyxUpdate <
1142+ | typeof ONYXKEYS . COLLECTION . SHARED_NVP_PRIVATE_DOMAIN_MEMBER
1143+ | typeof ONYXKEYS . COLLECTION . DOMAIN_ERRORS
1144+ | typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS
1145+ | typeof ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE
1146+ >
11271147 > = [
11281148 {
11291149 onyxMethod : Onyx . METHOD . MERGE ,
@@ -1138,9 +1158,20 @@ function toggleTwoFactorAuthRequiredForDomain(domainAccountID: number, domainNam
11381158 onyxMethod : Onyx . METHOD . MERGE ,
11391159 key : `${ ONYXKEYS . COLLECTION . DOMAIN_ERRORS } ${ domainAccountID } ` ,
11401160 value : {
1141- setTwoFactorAuthRequiredError : getMicroSecondOnyxErrorWithTranslationKey ( 'domain.members.forceTwoFactorAuthError' ) ,
1161+ setTwoFactorAuthRequiredError : twoFactorAuthCode ? null : getMicroSecondOnyxErrorWithTranslationKey ( 'domain.members.forceTwoFactorAuthError' ) ,
11421162 } ,
11431163 } ,
1164+ ...( twoFactorAuthCode
1165+ ? [
1166+ {
1167+ onyxMethod : Onyx . METHOD . MERGE ,
1168+ key : ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE ,
1169+ value : {
1170+ errors : getMicroSecondOnyxErrorWithTranslationKey ( 'domain.members.forceTwoFactorAuthError' ) ,
1171+ } ,
1172+ } as OnyxUpdate < typeof ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE > ,
1173+ ]
1174+ : [ ] ) ,
11441175 {
11451176 onyxMethod : Onyx . METHOD . MERGE ,
11461177 key : `${ ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS } ${ domainAccountID } ` ,
@@ -1166,6 +1197,10 @@ function clearToggleTwoFactorAuthRequiredForDomainError(domainAccountID: number)
11661197 } ) ;
11671198}
11681199
1200+ function clearValidateDomainTwoFactorCodeError ( ) {
1201+ Onyx . set ( ONYXKEYS . VALIDATE_DOMAIN_TWO_FACTOR_CODE , null ) ;
1202+ }
1203+
11691204function setDomainVacationDelegate ( domainAccountID : number , domainMemberAccountID : number , creator : string , vacationer : string , delegate : string , vacationDelegate ?: BaseVacationDelegate ) {
11701205 const optimisticData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . DOMAIN | typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS | typeof ONYXKEYS . COLLECTION . DOMAIN_ERRORS > > = [
11711206 {
@@ -1424,6 +1459,7 @@ export {
14241459 closeUserAccount ,
14251460 toggleTwoFactorAuthRequiredForDomain ,
14261461 clearToggleTwoFactorAuthRequiredForDomainError ,
1462+ clearValidateDomainTwoFactorCodeError ,
14271463 setDomainVacationDelegate ,
14281464 deleteDomainVacationDelegate ,
14291465 clearVacationDelegateError ,
0 commit comments