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) { 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) {

View file

@ -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,