mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
Merge 838527a9ac into 079ec865e0
This commit is contained in:
commit
9f8c9b70fb
2 changed files with 16 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue