mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 11:30:13 +08:00
feat(i18n): add localized content for authentication error
This commit is contained in:
1 parent
bd1d5af699
commit
013a5acaa7
5 files changed
+46
-15
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import api from './api'
|
||||
import { i18n } from '../i18n'
|
||||
|
||||
import {
|
||||
TooManyRequestsError,
|
||||
@@ -32,11 +33,15 @@ function handleRequestError(err: {
|
||||
const { path, msg } = errors[0]
|
||||
switch (path) {
|
||||
case 'username':
|
||||
throw new ValidationError('Username is already taken')
|
||||
throw new ValidationError(
|
||||
i18n.global.t('authform_error.username_taken')
|
||||
)
|
||||
case 'email':
|
||||
throw new ValidationError('Email is already taken')
|
||||
throw new ValidationError(i18n.global.t('authform_error.email_taken'))
|
||||
case 'password':
|
||||
throw new ValidationError('Password is too weak')
|
||||
throw new ValidationError(
|
||||
i18n.global.t('authform_error.invalid_password')
|
||||
)
|
||||
default:
|
||||
throw new ValidationError(msg)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user