@@ -194,6 +194,7 @@ import NcPasswordField from '@nextcloud/vue/components/NcPasswordField'
194194import NcRichText from ' @nextcloud/vue/components/NcRichText'
195195
196196import ModalVerificationCode from ' ./ModalVerificationCode.vue'
197+ import { NON_RETRIABLE_SIGN_ERROR_CODE , shouldCloseCurrentModalOnSignError } from ' ./signErrorUtils'
197198import Draw from ' ../../../components/Draw/Draw.vue'
198199import Documents from ' ../../../views/Account/partials/Documents.vue'
199200import Signatures from ' ../../../views/Account/partials/Signatures.vue'
@@ -301,10 +302,7 @@ defineOptions({
301302 this .actionHandler .showModal (modalCode )
302303 }
303304
304- const shouldCloseModal = (methodConfig .modalCode || methodConfig .method || ' token' ) === ' password'
305- && Array .isArray (signError .errors )
306- && signError .errors .some ((error ) => Number (error ?.code ) === 422 )
307- if (shouldCloseModal ) {
305+ if (shouldCloseCurrentModalOnSignError (methodConfig , signError )) {
308306 this .actionHandler .closeModal (methodConfig .modalCode || methodConfig .method || ' token' )
309307 }
310308
@@ -371,21 +369,6 @@ type SignSubmissionError = {
371369 errors? : SignError []
372370}
373371
374- const NON_RETRIABLE_SIGN_ERROR_CODE = 422
375-
376- function shouldCloseCurrentModalOnSignError(
377- methodConfig : SignatureMethodConfig ,
378- signError : SignSubmissionError ,
379- ): boolean {
380- const modalCode = methodConfig .modalCode || methodConfig .method || ' token'
381- if (modalCode !== ' password' ) {
382- return false
383- }
384-
385- const errors = Array .isArray (signError .errors ) ? signError .errors : []
386- return errors .some ((error ) => Number (error ?.code ) === NON_RETRIABLE_SIGN_ERROR_CODE )
387- }
388-
389372type SignStoreContract = ReturnType <typeof useSignStore > & {
390373 document: SignDocument
391374 errors: SignError []
0 commit comments