How to customize password complexity calculation for aps/Password widget
Modified on: Fri, 17 Nov 2023 12:07 PMOriginal Publishing Date:
2020-01-22
2020-01-22
Symptoms
I am trying to use the aps/Password widget in my application.
By default, it only takes into account password length when setting password complexity.
How do I replace that with my own password complexity calculation logic?
Resolution
You should create your own 'calcStrength' method.
For example, this is how I can make my widget set maximum password complexity when user enters 'password' for password and minimum in all other cases:
<html>
<head>
<script src="/aps/2/ui/runtime/client/aps/aps.js"></script>
<script>
require(["dojo/parser", "aps/Password", "aps/ready!"], function(parser, Password){
pwd = new Password();
pwd.calcStrength = function(value){return (value == "password") ? this.classesMap.length : 0; };
pwd.placeAt("body", "last");
parser.parse();
});
</script>
</head>
<body>
<div dojoType="aps/PageContainer">
<div id="body"></div>
</div>
</body>
</html>
Refer to the aps/Password widget documentation page page for more information.