0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(core): error data bug fixing (#6382)

fix(core): error code bug fixing

error code bug fixing
This commit is contained in:
simeng-li 2024-08-02 09:31:48 +08:00 committed by GitHub
parent ebb6a91de7
commit 0671208d0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -51,7 +51,7 @@ export class PasswordValidator {
);
if (issues.length > 0) {
throw new RequestError({ code: 'password.rejected', status: 422 }, { issues });
throw new RequestError({ code: 'password.rejected', status: 422 }, issues);
}
if (this.user) {

View file

@ -284,15 +284,15 @@ export class Mfa {
return;
}
const requiredFactors = factors.filter((factor) => factor !== MfaFactor.BackupCode);
const availableFactors = factors.filter((factor) => factor !== MfaFactor.BackupCode);
const factorsInUser = filterOutEmptyBackupCodes(mfaVerifications).map(({ type }) => type);
const factorsInBind = this.bindMfaFactorsArray.map(({ type }) => type);
const availableFactors = deduplicate([...factorsInUser, ...factorsInBind]);
const linkedFactors = deduplicate([...factorsInUser, ...factorsInBind]);
// Assert that the user has at least one of the required factors bound
assertThat(
requiredFactors.some((factor) => availableFactors.includes(factor)),
availableFactors.some((factor) => linkedFactors.includes(factor)),
new RequestError(
{ code: 'user.missing_mfa', status: 422 },
policy === MfaPolicy.Mandatory
@ -303,7 +303,7 @@ export class Mfa {
// Assert backup code
assertThat(
!factors.includes(MfaFactor.BackupCode) || availableFactors.includes(MfaFactor.BackupCode),
!factors.includes(MfaFactor.BackupCode) || linkedFactors.includes(MfaFactor.BackupCode),
new RequestError({
code: 'session.mfa.backup_code_required',
status: 422,