These functions work with the site user password rules set up in iCM.
getPasswordRulesDescription
Returns a human readable description of the current password rules.
Example
function(params, credentials) {
let request = this.callWorkerMethod('formutils', 'getpasswordrulesdescription', {});
return request;
}
Returns
{
"id": 45,
"result": {
"data": "Passwords must contain at least 8 characters,<br>at least 1 special character,<br>at least 1 numeric character,<br>at least 1 lower case letter<br>and no more than two of the same characters in a row.",
"success": true
},
"jsonrpc": "2.0"
}
getPasswordRulesJavascript
Returns a string containing a JavaScript function definition that takes a password and checks the password parameter, returning either an empty string on success or an error message.
Parameters | Type | Description |
---|---|---|
functionname | String, optional | Override the default function name |
Example
function(params, credentials) {
let request = this.callWorkerMethod('formutils', 'getpasswordrulesjavascript', {
"functionname": "MyFunction"
});
return request;
}
Returns
{
"id": 49,
"result": {
"data": "\n// MyFunction(password) - returns an empty string on success, or a description of the error\nfunction MyFunction(password){\nvar validationErrs = [];\nif (password.length < 8) {\nvalidationErrs.push('at least 8 characters');\n}\nvar PasswordMinSpecialChar = password.match(/[^0-9a-zA-Z]/g);\nif (PasswordMinSpecialChar == null || PasswordMinSpecialChar.length < 1) {\nvalidationErrs.push('at least 1 special character');\n}\nvar PasswordMinNumericChar = password.match(/[0-9]/g);\nif (PasswordMinNumericChar == null || PasswordMinNumericChar.length < 1) {\nvalidationErrs.push('at least 1 numeric character');\n}\nvar PasswordMinLowercaseChar = password.match(/[a-z]/g);\nif (PasswordMinLowercaseChar == null || PasswordMinLowercaseChar.length < 1) {\nvalidationErrs.push('at least 1 lower case letter');\n}\nvar BlockRepeatedCharsInPasswords = password.match(/(.)\\1\\1/g);\nif (BlockRepeatedCharsInPasswords != null && BlockRepeatedCharsInPasswords.length != 0) {\nvalidationErrs.push('no more than two of the same characters in a row');\n}\nif ( validationErrs.length > 0 ) {\nif(validationErrs.length > 1) {\nvalidationErrs[validationErrs.length-1] = 'and ' + validationErrs[validationErrs.length-1];\n}\nreturn 'Please enter a password that has:\\n' + validationErrs.join(',\\n') + '.';\n} else {\nreturn '';\n}\n}\n",
"success": true
},
"jsonrpc": "2.0"
}
validatePasswordAgainstRules
Validates the supplied password against the rules, returning either an empty string on success, the failed password rules on failure, or an error message.
Parameters | Type | Description |
---|---|---|
password | String, required | The password to check |
Example
function(params, credentials) {
let request = this.callWorkerMethod('formutils', 'validatepasswordagainstrules', {
"password": "reallybad"
});
return request;
}
Returns
{
"id": 53,
"result": {
"data": "Please enter a password that has:<br>at least 1 special character<br>and at least 1 numeric character.",
"success": true
},
"jsonrpc": "2.0"
}