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:
parent
ebb6a91de7
commit
0671208d0f
2 changed files with 5 additions and 5 deletions
|
@ -51,7 +51,7 @@ export class PasswordValidator {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (issues.length > 0) {
|
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) {
|
if (this.user) {
|
||||||
|
|
|
@ -284,15 +284,15 @@ export class Mfa {
|
||||||
return;
|
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 factorsInUser = filterOutEmptyBackupCodes(mfaVerifications).map(({ type }) => type);
|
||||||
const factorsInBind = this.bindMfaFactorsArray.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
|
// Assert that the user has at least one of the required factors bound
|
||||||
assertThat(
|
assertThat(
|
||||||
requiredFactors.some((factor) => availableFactors.includes(factor)),
|
availableFactors.some((factor) => linkedFactors.includes(factor)),
|
||||||
new RequestError(
|
new RequestError(
|
||||||
{ code: 'user.missing_mfa', status: 422 },
|
{ code: 'user.missing_mfa', status: 422 },
|
||||||
policy === MfaPolicy.Mandatory
|
policy === MfaPolicy.Mandatory
|
||||||
|
@ -303,7 +303,7 @@ export class Mfa {
|
||||||
|
|
||||||
// Assert backup code
|
// Assert backup code
|
||||||
assertThat(
|
assertThat(
|
||||||
!factors.includes(MfaFactor.BackupCode) || availableFactors.includes(MfaFactor.BackupCode),
|
!factors.includes(MfaFactor.BackupCode) || linkedFactors.includes(MfaFactor.BackupCode),
|
||||||
new RequestError({
|
new RequestError({
|
||||||
code: 'session.mfa.backup_code_required',
|
code: 'session.mfa.backup_code_required',
|
||||||
status: 422,
|
status: 422,
|
||||||
|
|
Loading…
Reference in a new issue