fix(backend/SigninApiService): ログインのレートリミット時、意図したものと違うエラーメッセージが表示される可能性がある問題を修正 (MisskeyIO#903)

This commit is contained in:
あわわわとーにゅ 2025-01-17 16:49:16 +09:00 committed by GitHub
parent f60d9da614
commit 71c2921b9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

@ -97,10 +97,15 @@ export class SigninApiService {
reply.code(429);
return {
error: {
message: 'Too many failed attempts to sign in. Try again later.',
code: 'TOO_MANY_AUTHENTICATION_FAILURES',
message: 'Rate limit exceeded. Please try again later.',
code: 'RATE_LIMIT_EXCEEDED',
id: '22d05606-fbcf-421a-a2db-b32610dcfd1b',
info: {
message: 'Too many failed attempts to sign in.',
code: 'TOO_MANY_AUTHENTICATION_FAILURES',
id: '6c181469-ecb9-42d2-82c9-60db5486a819',
},
}
};
}

View file

@ -79,7 +79,7 @@ export async function apiErrorHandler(err: Misskey.api.APIError, endpoint?: stri
} else if (err.code === 'ROLE_PERMISSION_DENIED') {
title = i18n.ts.permissionDeniedError;
text = i18n.ts.permissionDeniedErrorDescription;
} else if (err.code?.startsWith('TOO_MANY')) {
} else if (err.code?.startsWith('TOO_MANY_')) {
title = i18n.ts.youCannotCreateAnymore;
text = `${i18n.ts.error}: ${err.id}`;
}