View | Details | Raw Unified | Return to bug 18298
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/password_check.inc (+25 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% BLOCK add_password_check %]
3
<script type="text/javascript">
4
    var pwd_title = "";
5
    var pattern_title = "";
6
    var new_password_node_name = "[% new_password %]";
7
    [% IF Koha.Preference('RequireStrongPassword') %]
8
        pwd_title = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers").format([% minPasswordLength %]);
9
        pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% minPasswordLength %],}/;
10
    [% ELSIF minPasswordLength %]
11
        pwd_title = _("Password must contain at least %s characters").format([% minPasswordLength %]);
12
        pattern_regex = /.{[% minPasswordLength %],}/;
13
    [% END %]
14
    jQuery.validator.addMethod("password_strong", function(value, element){
15
        return this.optional(element) || value == '****' || pattern_regex.test(value);
16
    }, pwd_title);
17
    jQuery.validator.addMethod("password_no_spaces", function(value, element){
18
        return ( this.optional(element) || !value.match(/^\s/) && !value.match(/\s$/) );
19
    }, _("Password contains leading and/or trailing spaces"));
20
    jQuery.validator.addMethod("password_match", function(value, element){
21
        var new_password_node = $("input[name='" + new_password_node_name + "']:first");
22
        return this.optional(element) || value == $(new_password_node).val();
23
    }, _("Please enter the same password as above"));
24
</script>
25
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt (-36 / +34 lines)
Lines 1-3 Link Here
1
[% USE Koha %]
1
[% USE Branches %]
2
[% USE Branches %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Patrons &rsaquo; [% IF ( newpassword ) %]Password updated [% ELSE %]Update password for [% surname %], [% firstname %][% END %]</title>
4
<title>Koha &rsaquo; Patrons &rsaquo; [% IF ( newpassword ) %]Password updated [% ELSE %]Update password for [% surname %], [% firstname %][% END %]</title>
Lines 5-32 Link Here
5
<script type="text/JavaScript">
6
<script type="text/JavaScript">
6
//<![CDATA[
7
//<![CDATA[
7
8
8
    function check_password( password ) {
9
        if ( password.match(/^\s/) || password.match(/\s$/)) {
10
            return false;
11
        }
12
        return true;
13
    }
14
15
    $(document).ready(function() {
9
    $(document).ready(function() {
16
        var MSG_PASSWORD_CONTAINS_TRAILING_SPACES = _("Password contains leading and/or trailing spaces.");
17
        $("#changepasswordf").submit(function(){
18
            if($("input[name='newpassword']").val() != $("input[name='newpassword2']").val()){
19
                alert(_("Passwords do not match"));
20
                return false;
21
            } else {
22
                if ( ! check_password( $("input[name='newpassword']").val() ) ) {
23
                  alert(MSG_PASSWORD_CONTAINS_TRAILING_SPACES);
24
                  return false;
25
              } else {
26
                return true;
27
}
28
            }
29
        });
30
        $("body").on('click', "#fillrandom",function(e) {
10
        $("body").on('click', "#fillrandom",function(e) {
31
            e.preventDefault();
11
            e.preventDefault();
32
            $.get("/cgi-bin/koha/members/member-password.pl?member=[% userid %]", function(response) {
12
            $.get("/cgi-bin/koha/members/member-password.pl?member=[% userid %]", function(response) {
Lines 46-51 Link Here
46
            $("input[name^=newpassword]").show();
26
            $("input[name^=newpassword]").show();
47
            $("label[for=newpassword2]").show();
27
            $("label[for=newpassword2]").show();
48
            $(".loading").hide();
28
            $(".loading").hide();
29
            $("label.error").hide();
30
        });
31
        [% IF NOMATCH %]
32
            $("#newpassword").addClass('focus');
33
        [% END %]
34
35
        $("#changepasswordf").validate({
36
            rules: {
37
                newpassword: {
38
                    required: true,
39
                    password_strong: true,
40
                    password_no_spaces: true
41
                },
42
                newpassword2: {
43
                    required: true,
44
                    password_match: true
45
                }
46
            }
49
        });
47
        });
50
    });
48
    });
51
//]]>
49
//]]>
Lines 98-118 Link Here
98
	<ol>
96
	<ol>
99
    <li><label for="newuserid">New username:</label>
97
    <li><label for="newuserid">New username:</label>
100
	<input type="hidden" name="member" value="[% borrowernumber %]" /><input type="text" id="newuserid" name="newuserid" size="20" value="[% userid %]" /></li>
98
	<input type="hidden" name="member" value="[% borrowernumber %]" /><input type="text" id="newuserid" name="newuserid" size="20" value="[% userid %]" /></li>
101
    <li><label for="newpassword">New password:</label>
99
    [% SET password_pattern = ".{" _ minPasswordLength _ ",}" %]
102
    <div class="hint">Koha cannot display existing passwords. Leave the field blank to leave password unchanged.</div>
100
    [% IF Koha.Preference('RequireStrongPassword') %]
103
	[% IF ( minPasswordLength ) %]<div class="hint">Minimum password length: [% minPasswordLength %]</div>[% END %]
101
        [% SET password_pattern = '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{' _ minPasswordLength _ ',}' %]
104
	[% IF ( NOMATCH ) %]
102
    [% END %]
105
	<input name="newpassword"  id="newpassword" type="password" size="20" class="focus" />
103
    <li>
106
	<input name="newpassword" id="newpassword_random" readonly="readonly" disabled="disabled" type="hidden" />
104
        <label for="newpassword">New password:</label>
107
	[% ELSE %]
105
        <div class="hint">Koha cannot display existing passwords. Leave the field blank to leave password unchanged.</div>
108
	<input name="newpassword"  id="newpassword" type="password" size="20" />
106
        <input name="newpassword"  id="newpassword" type="password" size="20" />
109
	<input name="newpassword" readonly="readonly" disabled="disabled" type="hidden" />
107
    </li>
110
	[% END %]
108
    <li>
111
	</li>
109
        <label for="newpassword2">Confirm new password:</label>
112
    <li><label for="newpassword2">Confirm new password:</label>
110
        <input name="newpassword2"  id="newpassword2" type="password" size="20" />
113
	<input name="newpassword2"  id="newpassword2" type="password" size="20" />
111
    </li>
114
	<input name="newpassword2" id="newpassword2_random" readonly="readonly" disabled="disabled" type="hidden" />
115
	</li>
116
	</ol>
112
	</ol>
117
</fieldset>
113
</fieldset>
118
    <fieldset class="action">
114
    <fieldset class="action">
Lines 131-133 Link Here
131
</div>
127
</div>
132
</div>
128
</div>
133
[% INCLUDE 'intranet-bottom.inc' %]
129
[% INCLUDE 'intranet-bottom.inc' %]
130
[% PROCESS 'password_check.inc' %]
131
[% PROCESS 'add_password_check' new_password => 'newpassword' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-3 / +17 lines)
Lines 72-77 $(document).ready(function() { Link Here
72
        }
72
        }
73
        else {return false;}
73
        else {return false;}
74
    });
74
    });
75
76
    $("#entryform").validate({
77
        rules: {
78
            password: {
79
                required: true,
80
                password_strong: true,
81
                password_no_spaces: true
82
            },
83
            password2: {
84
                required: true,
85
                password_match: true
86
            }
87
        }
88
    });
89
75
    $("#saverecord").click(function(){
90
    $("#saverecord").click(function(){
76
        if( check_form_borrowers() ){
91
        if( check_form_borrowers() ){
77
            $("#entryform").submit();
92
            $("#entryform").submit();
Lines 88-95 $(document).ready(function() { Link Here
88
        var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
103
        var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
89
        var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
104
        var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
90
        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
105
        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
91
        var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match");
92
        var MSG_PASSWORD_CONTAINS_TRAILING_SPACES = _("Password contains leading and/or trailing spaces.");
93
        var MSG_MONTH = _("%s month")
106
        var MSG_MONTH = _("%s month")
94
        var MSG_MONTHS = _("%s months")
107
        var MSG_MONTHS = _("%s months")
95
        var MSG_YEAR = _("%s year")
108
        var MSG_YEAR = _("%s year")
Lines 1234-1237 $(document).ready(function() { Link Here
1234
[% END %]
1247
[% END %]
1235
</div>
1248
</div>
1236
[% INCLUDE 'intranet-bottom.inc' %]
1249
[% INCLUDE 'intranet-bottom.inc' %]
1237
1250
[% PROCESS 'password_check.inc' %]
1251
[% PROCESS 'add_password_check' new_password => 'password' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-14 lines)
Lines 103-122 function check_form_borrowers(nav){ Link Here
103
            }
103
            }
104
        }
104
        }
105
    }
105
    }
106
    if ( document.form.password ) {
107
        if ( document.form.password.value != document.form.password2.value ){
108
            if ( message_champ !== '' ){
109
                message_champ += "\n";
110
            }
111
            message_champ+= MSG_PASSWORD_MISMATCH;
112
            statut=1;
113
        }
114
115
        if ( ! check_password( document.form.password.value ) ) {
116
            message_champ += MSG_PASSWORD_CONTAINS_TRAILING_SPACES;
117
            statut = 1;
118
        }
119
    }
120
106
121
    //patrons form to test if you checked no to the question of double
107
    //patrons form to test if you checked no to the question of double
122
    if (statut!=1 && document.form.check_member.value > 0 ) {
108
    if (statut!=1 && document.form.check_member.value > 0 ) {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc (+25 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% BLOCK add_password_check %]
3
<script type="text/javascript">
4
    var pwd_title = "";
5
    var pattern_title = "";
6
    var new_password_node_name = "[% new_password %]";
7
    [% IF Koha.Preference('RequireStrongPassword') %]
8
        pwd_title = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers").format([% minPasswordLength %]);
9
        pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% minPasswordLength %],}/;
10
    [% ELSIF minPasswordLength %]
11
        pwd_title = _("Password must contain at least %s characters").format([% minPasswordLength %]);
12
        pattern_regex = /.{[% minPasswordLength %],}/;
13
    [% END %]
14
    jQuery.validator.addMethod("password_strong", function(value, element){
15
        return this.optional(element) || pattern_regex.test(value);
16
    }, pwd_title);
17
    jQuery.validator.addMethod("password_no_spaces", function(value, element){
18
        return ( this.optional(element) || !value.match(/^\s/) && !value.match(/\s$/) );
19
    }, _("Password contains leading and/or trailing spaces"));
20
    jQuery.validator.addMethod("password_match", function(value, element){
21
        var new_password_node = $("input[name='" + new_password_node_name + "']:first");
22
        return this.optional(element) || value == $(new_password_node).val();
23
    }, _("Please enter the same password as above"));
24
</script>
25
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (+18 lines)
Lines 987-992 Link Here
987
[% INCLUDE 'opac-bottom.inc' %]
987
[% INCLUDE 'opac-bottom.inc' %]
988
[% BLOCK jsinclude %]
988
[% BLOCK jsinclude %]
989
    <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.validate.min.js"></script>
989
    <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.validate.min.js"></script>
990
    [% PROCESS 'password_check.inc' %]
991
    [% PROCESS 'add_password_check' new_password => 'borrower_password' %]
990
    <script type="text/javascript">
992
    <script type="text/javascript">
991
        //<![CDATA[
993
        //<![CDATA[
992
        $(document).ready(function() {
994
        $(document).ready(function() {
Lines 1011-1016 Link Here
1011
                    },
1013
                    },
1012
                    borrower_B_email: {
1014
                    borrower_B_email: {
1013
                        email: true
1015
                        email: true
1016
                    },
1017
                    borrower_password: {
1018
                        [% IF mandatory.defined('password') %]
1019
                        required: true,
1020
                        [% END %]
1021
                        password_strong: true,
1022
                        password_no_spaces: true
1023
                    },
1024
                    borrower_password2: {
1025
                        [% IF mandatory.defined('password') %]
1026
                        required: true,
1027
                        [% END %]
1028
                        password_match: true
1029
                    },
1030
                    captcha: {
1031
                        required: true,
1014
                    }
1032
                    }
1015
                },
1033
                },
1016
                submitHandler: function(form) {
1034
                submitHandler: function(form) {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-passwd.tt (-2 / +23 lines)
Lines 47-52 Link Here
47
47
48
                    [% IF ( OpacPasswordChange ) %]
48
                    [% IF ( OpacPasswordChange ) %]
49
                        [% IF ( Ask_data ) %]
49
                        [% IF ( Ask_data ) %]
50
50
                            <form action="/cgi-bin/koha/opac-passwd.pl" name="mainform" id="mainform" method="post">
51
                            <form action="/cgi-bin/koha/opac-passwd.pl" name="mainform" id="mainform" method="post">
51
                                <fieldset>
52
                                <fieldset>
52
                                    [% UNLESS ( ShortPass ) %]<div class="alert alert-info">Your password must be at least [% minpasslen %] characters long.</div>[% END %]
53
                                    [% UNLESS ( ShortPass ) %]<div class="alert alert-info">Your password must be at least [% minpasslen %] characters long.</div>[% END %]
Lines 80-83 Link Here
80
81
81
82
82
[% INCLUDE 'opac-bottom.inc' %]
83
[% INCLUDE 'opac-bottom.inc' %]
83
[% BLOCK jsinclude %][% END %]
84
[% BLOCK jsinclude %]
85
    <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.validate.min.js"></script>
86
    [% PROCESS 'password_check.inc' %]
87
    [% PROCESS 'add_password_check' new_password => 'Newkey' %]
88
    <script type="text/javascript">
89
        $(document).ready(function() {
90
            $("#mainform").validate({
91
                rules: {
92
                    Newkey: {
93
                        required: true,
94
                        password_strong: true,
95
                        password_no_spaces: true
96
                    },
97
                    Confirm: {
98
                        required: true,
99
                        password_match: true
100
                    }
101
                }
102
            });
103
        });
104
    </script>
105
[% END %]
84
- 

Return to bug 18298