Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4264 password policy configuration #2301

Merged
merged 16 commits into from
Jan 17, 2024
Merged

Conversation

yagudin10
Copy link
Member

No description provided.

@yagudin10 yagudin10 changed the title CB-4491 password policy config api CB-4264 password policy configuration Jan 15, 2024
@devnaumov devnaumov marked this pull request as ready for review January 16, 2024 16:16
minSpecialCharacters: 0,
};

type ValidationResult = { isValid: true; errorMessage: null } | { isValid: false; errorMessage: string };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to use:

interface IPasswordValidationSatus {
  isValid: boolean;
  message: string;
}

Copy link
Member

@devnaumov devnaumov Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there is no message if the status is valid
if(isValid) {message is null here}

};
}

if (this.config.requiresUpperLowerCase && !(/[a-z]/.test(password) && /[A-Z]/.test(password))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets create a file for a regexps. so it is reusable and in one place

const lowerCaseRegExp = /[a-z]/
const upperCaseRegExp = /[A-Z]/

Copy link
Member

@devnaumov devnaumov Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can find a place for it after we will have a second use case

};
}

if ((password.match(/[!@#$%^&*(),.?":{}|<>]/g) || []).length < this.config.minSpecialCharacters) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to regExp file

return { isValid: false, errorMessage: this.localizationService.translate('core_authentication_password_policy_upper_lower_case') };
}

if ((password.match(/\d/g) || []).length < this.config.minDigits) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to regExp file

@devnaumov devnaumov merged commit 8ba0eb6 into devel Jan 17, 2024
2 of 3 checks passed
@serge-rider serge-rider deleted the CB-4264-password-policy branch February 21, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants