Skip to content

Commit

Permalink
Add max limit for rules and values
Browse files Browse the repository at this point in the history
  • Loading branch information
PasinduYeshan committed Aug 15, 2024
1 parent bb89947 commit 35f908b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ export class GovernanceConnectorConstants {
EXPIRY_TIME_MIN_LENGTH: number;
EXPIRY_TIME_MIN_VALUE: number;
EXPIRY_RULES_MAX_COUNT: number;
EXPIRY_RULE_MAX_VALUES_PER_RULE: number;
} = {
EXPIRY_RULES_MAX_COUNT: 10,
EXPIRY_RULE_MAX_VALUES_PER_RULE: 5,
EXPIRY_TIME_MAX_LENGTH: 5,
EXPIRY_TIME_MAX_VALUE: 10080,
EXPIRY_TIME_MIN_LENGTH: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export const PasswordExpiryRuleList: FunctionComponent<PasswordExpiryRuleListPro
* Add a new rule.
*/
const addRule = () => {
if (rules?.length >= GovernanceConnectorConstants.PASSWORD_EXPIRY_FORM_FIELD_CONSTRAINTS.
EXPIRY_RULES_MAX_COUNT) return;

const newRule: PasswordExpiryRule = {
attribute: PasswordExpiryRuleAttribute.ROLES,
expiryDays: 30,
Expand Down Expand Up @@ -227,7 +230,7 @@ export const PasswordExpiryRuleList: FunctionComponent<PasswordExpiryRuleListPro
const validList: Resource[] = isRole ? rolesList : groupsList;
const validatedValues: string[] = selectedValues.filter((selectedValue: string) =>
validList.some((item: Resource) => item.id === selectedValue)
);
).slice(0, GovernanceConnectorConstants.PASSWORD_EXPIRY_FORM_FIELD_CONSTRAINTS.EXPIRY_RULE_MAX_VALUES_PER_RULE);

handleRuleChange(
index,
Expand Down

0 comments on commit 35f908b

Please sign in to comment.