This commit is contained in:
萧瑟 2026-06-24 23:46:19 +09:00 committed by GitHub
commit 9f8c9b70fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View file

@ -26,6 +26,12 @@ export const meta = {
id: '0d7ec6d2-e652-443e-a7bf-9ee9a0cd77b0',
},
incorrectTotp: {
message: 'The one-time password is incorrect or has expired.',
code: 'INCORRECT_TOTP',
id: '57e56c36-e07e-49ab-97fb-7dc8a5b4cd50',
},
twoFactorNotEnabled: {
message: '2fa not enabled.',
code: 'TWO_FACTOR_NOT_ENABLED',
@ -76,13 +82,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (profile.twoFactorEnabled) {
if (token == null) {
throw new Error('authentication failed');
throw new ApiError(meta.errors.incorrectTotp);
}
try {
await this.userAuthService.twoFactorAuthenticate(profile, token);
} catch (_) {
throw new Error('authentication failed');
throw new ApiError(meta.errors.incorrectTotp);
}
}

View file

@ -30,6 +30,12 @@ export const meta = {
id: '38769596-efe2-4faf-9bec-abbb3f2cd9ba',
},
incorrectTotp: {
message: 'The one-time password is incorrect or has expired.',
code: 'INCORRECT_TOTP',
id: '0606da0a-a3c3-4215-8b87-30ecb63475c1',
},
twoFactorNotEnabled: {
message: '2fa not enabled.',
code: 'TWO_FACTOR_NOT_ENABLED',
@ -76,13 +82,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (profile.twoFactorEnabled) {
if (token == null) {
throw new Error('authentication failed');
throw new ApiError(meta.errors.incorrectTotp);
}
try {
await this.userAuthService.twoFactorAuthenticate(profile, token);
} catch (_) {
throw new Error('authentication failed');
throw new ApiError(meta.errors.incorrectTotp);
}
}