Skip to content

Commit

Permalink
fix: Unclear error message on password reset (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Nov 24, 2023
1 parent 0c35c6a commit 746f0f0
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions core/client/components/account/KResetPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,22 @@ async function apply () {
processing.value = false
} catch (error) {
processing.value = false
const type = _.get(error, 'errors.$className')
switch (type) {
case 'badParams':
message.value = i18n.t('KResetPassword.ERROR_MESSAGE_BAD_PARAMS')
break
case 'resetExpired':
message.value = i18n.t('KResetPassword.ERROR_MESSAGE_VERIFY_EXPIRED')
break
default:
message.value = i18n.t('KResetPassword.ERROR_MESSAGE_DEFAULT')
// Translate the error if we have a specific message, ie a translation key exists
const translation = _.get(error, 'data.translation')
if (translation) {
message.value = i18n.tie('errors.' + translation.key, translation.params)
} else { // Otherwise use a message linked to the generic error type
const type = _.get(error, 'errors.$className')
switch (type) {
case 'badParams':
message.value = i18n.t('KResetPassword.ERROR_MESSAGE_BAD_PARAMS')
break
case 'resetExpired':
message.value = i18n.t('KResetPassword.ERROR_MESSAGE_VERIFY_EXPIRED')
break
default:
message.value = i18n.t('KResetPassword.ERROR_MESSAGE_DEFAULT')
}
}
}
send.value = true
Expand Down

0 comments on commit 746f0f0

Please sign in to comment.