diff --git a/resources/js/components/AuthModal.vue b/resources/js/components/AuthModal.vue index 3d1a278d9..d6c28cf67 100644 --- a/resources/js/components/AuthModal.vue +++ b/resources/js/components/AuthModal.vue @@ -1221,7 +1221,11 @@ const handleVerifyCode = async () => { clearMessages() loading.value = true - if (form.value.verificationCode?.length != 6) { + // Strip spaces and non-numeric characters from the code + const cleanCode = form.value.verificationCode?.replace(/[^0-9]/g, '') || '' + form.value.verificationCode = cleanCode + + if (cleanCode.length != 6) { setError(t('common.invalidCodeLength')) setTimeout(() => { clearMessages() @@ -1231,12 +1235,10 @@ const handleVerifyCode = async () => { } try { - await authStore - .verifyEmailVerification(form.value.email, form.value.verificationCode) - .then((res) => { - registrationStep.value = 3 - setSuccess(t('common.emailVerifiedSuccessfully')) - }) + await authStore.verifyEmailVerification(form.value.email, cleanCode).then((res) => { + registrationStep.value = 3 + setSuccess(t('common.emailVerifiedSuccessfully')) + }) } catch (err) { console.error('Verification error:', err) diff --git a/resources/js/pages/auth/app-register.vue b/resources/js/pages/auth/app-register.vue index 486736b8e..427aa60ce 100644 --- a/resources/js/pages/auth/app-register.vue +++ b/resources/js/pages/auth/app-register.vue @@ -751,7 +751,11 @@ const handleVerifyCode = async () => { clearMessages() loading.value = true - if (form.value.verificationCode?.length != 6) { + // Strip spaces and non-numeric characters from the code + const cleanCode = form.value.verificationCode?.replace(/[^0-9]/g, '') || '' + form.value.verificationCode = cleanCode + + if (cleanCode.length != 6) { setError(t('common.invalidCodeLength')) setTimeout(() => { clearMessages() @@ -761,12 +765,10 @@ const handleVerifyCode = async () => { } try { - await authStore - .verifyEmailVerification(form.value.email, form.value.verificationCode) - .then((res) => { - registrationStep.value = 3 - setSuccess(t('common.emailVerifiedSuccessfully')) - }) + await authStore.verifyEmailVerification(form.value.email, cleanCode).then((res) => { + registrationStep.value = 3 + setSuccess(t('common.emailVerifiedSuccessfully')) + }) } catch (err) { console.error('Verification error:', err)