Skip to content

Commit

Permalink
fix(verification): display error when the code is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyArt1 authored and akevinieron committed Jul 13, 2024
1 parent dabc1f4 commit b441125
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/app/[lang]/verification/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export function Form({ flow, returnTo, code }: Props) {
case 410:
// Status code 410 means the request has expired - so let's load a fresh flow!
case 403:
case 404:
// Status code 403 implies some other issue (e.g. CSRF) - let's reload!
setOtp(Array<string>(6).fill(''));
return router.push('/verification');
}

Expand Down Expand Up @@ -134,8 +136,12 @@ export function Form({ flow, returnTo, code }: Props) {
updateVerificationFlowBody: { method: 'code', code },
})
.then(({ data }) => {
// Form submission was successful, show the message to the user!
setCurrentFlow(data);
// Check for errors
const errors = data.ui.messages?.filter((msg) => msg.type === 'error');

if (errors?.length) {
throw new Error(errors.at(0)?.text);
}

router.push('/account-created');
})
Expand Down
2 changes: 1 addition & 1 deletion src/dictionaries/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
},
"code": {
"badUrl": "The code link is incorrect or has expired.",
"wrong": "The code is incorrect"
"wrong": "The code is incorrect or has expired."
},
"createIdentity": "An error occurred trying to create the citizen account. Please, try again later.",
"decryption": "Error decrypting:",
Expand Down
4 changes: 2 additions & 2 deletions src/dictionaries/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
"validation": "No podemos validar la seguridad de su navegador, verifique si tiene actualizaciones pendientes o intente con otro dispositivo."
},
"code": {
"badUrl": "Enlace del código es incorrecto o ha expirado",
"wrong": "El código es incorrecto"
"badUrl": "Enlace del código es incorrecto o ha expirado.",
"wrong": "El código es incorrecto o ha expirado."
},
"createIdentity": "Ha ocurrido un error intentando crear la cuenta ciudadana. Por favor, inténtelo más tarde.",
"decryption": "Error al desencriptar:",
Expand Down

0 comments on commit b441125

Please sign in to comment.