Merge pull request #789 from EternalSide/fix/add-passwordPolicy-maxLength
fix: add maxLength passwordPolicy in the getUserProfileApi
This commit is contained in:
commit
80988125e8
@ -769,6 +769,8 @@ export declare namespace Validators {
|
||||
export type PasswordPolicies = {
|
||||
/** The minimum length of the password */
|
||||
length?: number;
|
||||
/** The maximum length of the password */
|
||||
maxLength?: number;
|
||||
/** The minimum number of digits required in the password */
|
||||
digits?: number;
|
||||
/** The minimum number of lowercase characters required in the password */
|
||||
|
@ -509,6 +509,8 @@ function formStateSelector(params: { state: internal.State }): FormState {
|
||||
switch (error.source.name) {
|
||||
case "length":
|
||||
return hasLostFocusAtLeastOnce;
|
||||
case "maxLength":
|
||||
return hasLostFocusAtLeastOnce;
|
||||
case "digits":
|
||||
return hasLostFocusAtLeastOnce;
|
||||
case "lowerCase":
|
||||
@ -967,6 +969,34 @@ function createGetErrors(params: { kcContext: KcContextLike_useGetErrors }) {
|
||||
});
|
||||
}
|
||||
|
||||
check_password_policy_x: {
|
||||
const policyName = "maxLength";
|
||||
|
||||
const policy = passwordPolicies[policyName];
|
||||
|
||||
if (!policy) {
|
||||
break check_password_policy_x;
|
||||
}
|
||||
|
||||
const maxLength = policy;
|
||||
|
||||
if (value.length <= maxLength) {
|
||||
break check_password_policy_x;
|
||||
}
|
||||
|
||||
errors.push({
|
||||
advancedMsgArgs: [
|
||||
"invalidPasswordMaxLengthMessage" satisfies MessageKey_defaultSet,
|
||||
`${maxLength}`
|
||||
] as const,
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
check_password_policy_x: {
|
||||
const policyName = "digits";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user