mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-10 16:27:59 -04:00
Move all error translations to common.errors.* in browser extension
This commit is contained in:
@@ -40,7 +40,7 @@ const MobileUnlockModal: React.FC<IMobileUnlockModalProps> = ({
|
||||
const getErrorMessage = (errorCode: MobileLoginErrorCode): string => {
|
||||
switch (errorCode) {
|
||||
case MobileLoginErrorCode.TIMEOUT:
|
||||
return t('auth.errors.mobileLoginRequestExpired');
|
||||
return t('common.errors.mobileLoginRequestExpired');
|
||||
case MobileLoginErrorCode.GENERIC:
|
||||
default:
|
||||
return t('common.errors.unknownError');
|
||||
|
||||
@@ -287,9 +287,9 @@ const Login: React.FC = () => {
|
||||
setError(t('common.apiErrors.' + err.message));
|
||||
} else if (hasErrorCode(err)) {
|
||||
// Error contains an error code (E-XXX), show the formatted message as-is
|
||||
setError(getErrorMessage(err, t('auth.errors.serverError')));
|
||||
setError(getErrorMessage(err, t('common.errors.serverError')));
|
||||
} else {
|
||||
setError(t('auth.errors.serverError'));
|
||||
setError(t('common.errors.serverError'));
|
||||
}
|
||||
hideLoading();
|
||||
}
|
||||
@@ -312,7 +312,7 @@ const Login: React.FC = () => {
|
||||
// Validate that 2FA code is a 6-digit number
|
||||
const code = twoFactorCode.trim();
|
||||
if (!/^\d{6}$/.test(code)) {
|
||||
throw new Error(t('auth.errors.invalidCode'));
|
||||
throw new Error(t('common.errors.invalidCode'));
|
||||
}
|
||||
|
||||
const twoFaUsername = SrpAuthService.normalizeUsername(credentials.username);
|
||||
@@ -351,9 +351,9 @@ const Login: React.FC = () => {
|
||||
setError(t('common.apiErrors.' + err.message));
|
||||
} else if (hasErrorCode(err)) {
|
||||
// Error contains an error code (E-XXX), show the formatted message as-is
|
||||
setError(getErrorMessage(err, t('auth.errors.serverError')));
|
||||
setError(getErrorMessage(err, t('common.errors.serverError')));
|
||||
} else {
|
||||
setError(t('auth.errors.serverError'));
|
||||
setError(t('common.errors.serverError'));
|
||||
}
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ const Unlock: React.FC = () => {
|
||||
const sqliteClient = await dbContext.loadStoredDatabase();
|
||||
if (!sqliteClient) {
|
||||
// Edge case: no vault loaded but no error thrown (shouldn't happen)
|
||||
throw new Error(t('auth.errors.wrongPassword'));
|
||||
throw new Error(t('common.errors.wrongPassword'));
|
||||
}
|
||||
|
||||
// Check if there are pending migrations
|
||||
@@ -305,9 +305,9 @@ const Unlock: React.FC = () => {
|
||||
await app.logout(err.message);
|
||||
} else if (hasErrorCode(err)) {
|
||||
// Error contains an error code (E-XXX), show the formatted message as-is
|
||||
setError(getErrorMessage(err, t('auth.errors.wrongPassword')));
|
||||
setError(getErrorMessage(err, t('common.errors.wrongPassword')));
|
||||
} else {
|
||||
setError(t('auth.errors.wrongPassword'));
|
||||
setError(t('common.errors.wrongPassword'));
|
||||
}
|
||||
console.error('Unlock error:', err);
|
||||
} finally {
|
||||
|
||||
@@ -28,14 +28,7 @@
|
||||
"switchAccounts": "Switch accounts?",
|
||||
"loginWithMobile": "Log in using Mobile App",
|
||||
"unlockWithMobile": "Unlock using Mobile App",
|
||||
"scanQrCode": "Scan this QR code with your AliasVault mobile app to log in and unlock your vault.",
|
||||
"errors": {
|
||||
"invalidCode": "Please enter a valid 6-digit authentication code.",
|
||||
"serverError": "Could not reach AliasVault server. Please try again later or contact support if the problem persists.",
|
||||
"wrongPassword": "Incorrect password. Please try again.",
|
||||
"sessionExpired": "Your session has expired. Please log in again.",
|
||||
"mobileLoginRequestExpired": "Mobile login request timed out. Please reload the page and try again."
|
||||
}
|
||||
"scanQrCode": "Scan this QR code with your AliasVault mobile app to log in and unlock your vault."
|
||||
},
|
||||
"menu": {
|
||||
"vault": "Vault",
|
||||
@@ -106,7 +99,12 @@
|
||||
"vaultIsLocked": "Vault is locked",
|
||||
"passwordChanged": "Your password has changed since the last time you logged in. Please login again for security reasons.",
|
||||
"syncConflictMaxRetries": "Could not sync vault after multiple attempts. Please try again later.",
|
||||
"mergeFailed": "Failed to merge vault changes. Please try again."
|
||||
"mergeFailed": "Failed to merge vault changes. Please try again.",
|
||||
"invalidCode": "Please enter a valid 6-digit authentication code.",
|
||||
"serverError": "Could not reach AliasVault server. Please try again later or contact support if the problem persists.",
|
||||
"wrongPassword": "Incorrect password. Please try again.",
|
||||
"sessionExpired": "Your session has expired. Please log in again.",
|
||||
"mobileLoginRequestExpired": "Mobile login request timed out. Please reload the page and try again."
|
||||
},
|
||||
"apiErrors": {
|
||||
"UNKNOWN_ERROR": "An unknown error occurred. Please try again.",
|
||||
|
||||
@@ -78,7 +78,7 @@ export class WebApiService {
|
||||
|
||||
return parseJson ? retryResponse.json() : retryResponse as unknown as T;
|
||||
} else {
|
||||
logoutEventEmitter.emit('auth.errors.sessionExpired');
|
||||
logoutEventEmitter.emit('common.errors.sessionExpired');
|
||||
throw new ApiAuthError('Session expired');
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ export class WebApiService {
|
||||
this.updateTokens(tokenResponse.token, tokenResponse.refreshToken);
|
||||
return tokenResponse.token;
|
||||
} catch {
|
||||
logoutEventEmitter.emit('auth.errors.sessionExpired');
|
||||
logoutEventEmitter.emit('common.errors.sessionExpired');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user