Lines 1-25
Link Here
|
1 |
[% USE Koha %] |
1 |
[% USE Koha %] |
2 |
[% BLOCK add_password_check %] |
|
|
3 |
<script> |
2 |
<script> |
4 |
var pwd_title = ""; |
3 |
var pwd_title = ""; |
5 |
var pattern_title = ""; |
4 |
var pattern_title = ""; |
6 |
var new_password_node_name = "[% new_password | html %]"; |
5 |
var new_password_node_name = "[% new_password | html %]"; |
7 |
[% IF Koha.Preference('RequireStrongPassword') %] |
6 |
var category_selector = "[% category_selector | html %]"; |
8 |
pwd_title = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers").format([% minPasswordLength | html %]); |
7 |
var STRONG_MSG = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers"); |
9 |
pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% minPasswordLength | html %],}/; |
8 |
var WEAK_MSG = _("Password must contain at least %s characters"); |
10 |
[% ELSIF minPasswordLength %] |
9 |
|
11 |
pwd_title = _("Password must contain at least %s characters").format([% minPasswordLength | html %]); |
10 |
if(category_selector && $('select'+category_selector).length) { |
12 |
pattern_regex = /.{[% minPasswordLength | html %],}/; |
11 |
jQuery.validator.addMethod("password_strong", function(value, element){ |
13 |
[% END %] |
12 |
var require_strong = $('select'+category_selector+' option:selected').data('pwdStrong'); |
14 |
jQuery.validator.addMethod("password_strong", function(value, element){ |
13 |
var min_lenght = $('select'+category_selector+' option:selected').data('pwdLength'); |
15 |
return this.optional(element) || pattern_regex.test(value); |
14 |
var regex_text = require_strong?"(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{"+min_lenght+",}":".{"+min_lenght+",}"; |
16 |
}, pwd_title); |
15 |
var pattern_regex = new RegExp(regex_text); |
|
|
16 |
return this.optional(element) || pattern_regex.test(value); |
17 |
}, function(unused, element) { |
18 |
var require_strong = $('select'+category_selector+' option:selected').data('pwdStrong'); |
19 |
var min_lenght = $('select'+category_selector+' option:selected').data('pwdLength'); |
20 |
return (require_strong?STRONG_MSG:WEAK_MSG).format(min_lenght) |
21 |
}); |
22 |
} else { |
23 |
[% IF RequireStrongPassword %] |
24 |
pwd_title = STRONG_MSG.format([% minPasswordLength | html %]); |
25 |
pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% minPasswordLength | html %],}/; |
26 |
[% ELSIF minPasswordLength %] |
27 |
pwd_title = WEAK_MSG.format([% minPasswordLength | html %]); |
28 |
pattern_regex = /.{[% minPasswordLength | html %],}/; |
29 |
[% END %] |
30 |
jQuery.validator.addMethod("password_strong", function(value, element){ |
31 |
return this.optional(element) || value == '****' || pattern_regex.test(value); |
32 |
}, pwd_title); |
33 |
} |
17 |
jQuery.validator.addMethod("password_no_spaces", function(value, element){ |
34 |
jQuery.validator.addMethod("password_no_spaces", function(value, element){ |
18 |
return ( this.optional(element) || !value.match(/^\s/) && !value.match(/\s$/) ); |
35 |
return ( this.optional(element) || !value.match(/^\s/) && !value.match(/\s$/) ); |
19 |
}, _("Password contains leading and/or trailing spaces")); |
36 |
}, _("Password contains leading and/or trailing spaces")); |
20 |
jQuery.validator.addMethod("password_match", function(value, element){ |
37 |
jQuery.validator.addMethod("password_match", function(value, element){ |
21 |
var new_password_node = $("input[name='" + new_password_node_name + "']:first"); |
38 |
var new_password_node = $("input[name='" + new_password_node_name + "']:first"); |
22 |
return this.optional(element) || value == $(new_password_node).val(); |
39 |
return value == $(new_password_node).val(); |
23 |
}, _("Please enter the same password as above")); |
40 |
}, _("Please enter the same password as above")); |
24 |
</script> |
41 |
</script> |
25 |
[% END %] |
|
|