Hi,
I would like to know if i could customize the strength calculation process for p:password component. It would be great if there could be an attribute to this component which takes a regular expression and judges the strength based on that.
Or even more, have 3 attributes which take regular expression, one for each strength level (e.g. weakRegex, goodRegex, strongRegex).
Thanks
Can i customize p:password strength?
Hello,
The algorithm is embedded in the Primefaces javascript code. And thus can't be changed.
If needed, create a request to allow a new attribute that defines the name of a js function that needs to calculate the strength.
regards
Rudy
The algorithm is embedded in the Primefaces javascript code. And thus can't be changed.
If needed, create a request to allow a new attribute that defines the name of a js function that needs to calculate the strength.
regards
Rudy
PrimeFaces version 3.5, Tomcat 7, Mojarra 2.1.13
PrimeFaces version 4.0, Glassfish 4.0
PrimeFaces version 5.0, WLS 12.1.2
If you haven't read the forum rules read them now : viewtopic.php?f=3&t=1194
PrimeFaces version 4.0, Glassfish 4.0
PrimeFaces version 5.0, WLS 12.1.2
If you haven't read the forum rules read them now : viewtopic.php?f=3&t=1194
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Alternative way is to override;
Add your script at the pages where you have password components.
Ranges for levels;
0, 30 : Weak
30, 80 : Medium
80,100 : Strong
This turned out to be nice example of how to override PrimeFaces JS APIs
Code: Select all
PrimeFaces.widget.Password.prototype.testStrength= function(str) {
//return a number between 0 and 100.
}
Ranges for levels;
0, 30 : Weak
30, 80 : Medium
80,100 : Strong
This turned out to be nice example of how to override PrimeFaces JS APIs
Really very good example for overriding the Primefaces js APIs.If it is a bug fix/big change in JS code then I will prefer overriding enter JS file instead few code snippets.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
Optimus,
Indeed good example. I though the prototype method would be overwritten by the actual method.
Learning something new, have to test such a strategy.
regards
Rudy
Indeed good example. I though the prototype method would be overwritten by the actual method.
Learning something new, have to test such a strategy.
regards
Rudy
PrimeFaces version 3.5, Tomcat 7, Mojarra 2.1.13
PrimeFaces version 4.0, Glassfish 4.0
PrimeFaces version 5.0, WLS 12.1.2
If you haven't read the forum rules read them now : viewtopic.php?f=3&t=1194
PrimeFaces version 4.0, Glassfish 4.0
PrimeFaces version 5.0, WLS 12.1.2
If you haven't read the forum rules read them now : viewtopic.php?f=3&t=1194
In the past I overwritten 50% of PrimeFaces, but now 0% . Everything works more or less as expected. Regarding password strength - there is no customization options. But to write an own logic is quite simple with pure JavaScript and Reg Ex. There are 1000 examples in the web. I had to do this last week for an old application, can post later if somebody needs. Customization in JavaScript is not good, by the way. We had to write the script flexible and only customize input parameters coming from Java. So, the idea is to write the logic in the JS script once and customize it via parameters such as min. allowed count of input characters, groups of characters (digits, low, upper cases, special characters). Parameters are included in Reg Ex. At the end, there are two-three Reg Ex. to be customized for a week, medium, strong password.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
Interesting.But i feel writing the script logic which contain lots of RegEx may not be easy for major changes,it might be useful&easy for group of characters,min&max changes etc.If you already done for any component or sample use case will give a good idea on this.Oleg wrote:In the past I overwritten 50% of PrimeFaces, but now 0% . Everything works more or less as expected. Regarding password strength - there is no customization options. But to write an own logic is quite simple with pure JavaScript and Reg Ex. There are 1000 examples in the web. I had to do this last week for an old application, can post later if somebody needs. Customization in JavaScript is not good, by the way. We had to write the script flexible and only customize input parameters coming from Java. So, the idea is to write the logic in the JS script once and customize it via parameters such as min. allowed count of input characters, groups of characters (digits, low, upper cases, special characters). Parameters are included in Reg Ex. At the end, there are two-three Reg Ex. to be customized for a week, medium, strong password.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
-
- Information
-
Who is online
Users browsing this forum: No registered users and 64 guests