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?


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:

 <script src="/aps/2/ui/runtime/client/aps/aps.js"></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");
 <div dojoType="aps/PageContainer">
     <div id="body"></div>

Refer to the aps/Password widget documentation page page for more information.

Internal content