Bug 27631: labels and members folders
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / member-password.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>
8     [% IF ( newpassword ) %]Password updated [% ELSE %]Update password for [% patron.surname | html %], [% patron.firstname | html %][% END %] &rsaquo; Patrons &rsaquo; Koha
9 </title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 </head>
12
13 <body id="pat_member-password" class="pat">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'patron-search-header.inc' %]
16
17 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
18     <ol>
19         <li>
20             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
21         </li>
22         <li>
23             <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
24         </li>
25         <li>
26             <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
27         </li>
28         <li>
29             <a href="#" aria-current="page">
30                 [% IF ( newpassword ) %]
31                     Password updated
32                 [% ELSE %]
33                     Change username and/or password
34                 [% END %]
35             </a>
36         </li>
37     </ol>
38 </nav>
39
40 <div class="main container-fluid">
41     <div class="row">
42         <div class="col-sm-10 col-sm-push-2">
43             <main>
44
45 [% INCLUDE 'members-toolbar.inc' %]
46
47 [% IF ( newpassword ) %]
48 <h1>Password updated</h1>
49
50 [% ELSE %]
51
52 <form method="post" id="changepasswordf" action="/cgi-bin/koha/members/member-password.pl">
53 <input type="hidden" name="destination" value="[% destination | html %]" />
54 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
55         [% IF ( errormsg ) %]
56                 <div class="dialog alert">
57                 <h4>The following errors have occurred:</h4>
58                 <ul>
59                 [% IF ( BADUSERID ) %]
60         <li>You have entered a username that already exists. Please choose another one.</li>
61                 [% END %]
62         [% IF ( ERROR_password_too_short ) %]
63             <li id="ERROR_short_password">Password must be at least [% patron.category.effective_min_password_length | html %] characters long.</li>
64         [% END %]
65         [% IF ( ERROR_password_too_weak ) %]
66             <li id="ERROR_weak_password">Password must contain at least one digit, one lowercase and one uppercase.</li>
67         [% END %]
68         [% IF ( ERROR_password_has_whitespaces ) %]
69             <li id="ERROR_weak_password">Password must not contain leading or trailing whitespaces.</li>
70         [% END %]
71         [% IF ( ERROR_from_plugin ) %]
72             <li id="ERROR_from_plugin">The password was rejected by a plugin.</li>
73         [% END %]
74                 [% IF ( NOPERMISSION ) %]
75                 <li>You do not have permission to edit this patron's login information.</li>
76                 [% END %]
77                 [% IF ( NOMATCH ) %]
78                 <li><strong>The passwords entered do not match</strong>. Please re-enter the new password.</li>
79                 [% END %]
80                 </ul>
81                 </div>
82         [% END %]
83
84
85     <fieldset class="brief"><legend><h1>Change username and/or password for [% patron.firstname | html %] [% patron.surname | html %]</h1></legend>
86         <ol>
87     <li><label for="newuserid">New username:</label>
88     <input type="hidden" name="member" value="[% patron.borrowernumber | html %]" /><input type="text" id="newuserid" name="newuserid" size="20" value="[% patron.userid | html %]" /></li>
89     [% SET password_pattern = ".{" _ patron.category.effective_min_password_length _ ",}" %]
90     [% IF patron.category.effective_require_strong_password %]
91         [% SET password_pattern = '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{' _ patron.category.effective_min_password_length _ ',}' %]
92     [% END %]
93     <li>
94         <label for="newpassword">New password:</label>
95         <div class="hint">Koha cannot display existing passwords. Leave the field blank to leave password unchanged.</div>
96         <input name="newpassword"  id="newpassword" type="password" size="20" />
97     </li>
98     <li>
99         <label for="newpassword2">Confirm new password:</label>
100         <input name="newpassword2"  id="newpassword2" type="password" size="20" />
101     </li>
102         </ol>
103 </fieldset>
104     <fieldset class="action">
105         <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
106         <input type="submit" value="Save" />
107         <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
108     </fieldset>
109 </form>[% END %]
110
111
112 <div class="loading hide"><strong>Processing...</strong><img src="[% interface | html %]/[% theme | html %]/img/loading.gif" alt="" /></div>
113
114             </main>
115         </div> <!-- /.col-sm-10.col-sm-push-2 -->
116
117         <div class="col-sm-2 col-sm-pull-10">
118             <aside>
119                 [% INCLUDE 'circ-menu.inc' %]
120             </aside>
121         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
122     </div> <!-- /.row -->
123
124 [% MACRO jsinclude BLOCK %]
125     [% INCLUDE 'str/members-menu.inc' %]
126     [% Asset.js("js/members-menu.js") | $raw %]
127     <script>
128         function generate_password() {
129             // Always generate a strong password
130             var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
131             var length = [% patron.category.effective_min_password_length | html %];
132             if ( length < 8 ) length = 8;
133             var password='';
134             for ( var i = 0 ; i < length ; i++){
135                 password += chars.charAt(Math.floor(Math.random()*chars.length));
136             }
137             return password;
138         }
139         $(document).ready(function() {
140             $("body").on('click', "#fillrandom",function(e) {
141                 e.preventDefault();
142                 var password = '';
143                 var pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% patron.category.effective_min_password_length | html %],}/;
144                 while ( ! pattern_regex.test( password ) ) {
145                     password = generate_password();
146                 }
147                 $("#newpassword").val(password);
148                 $("#newpassword").attr('type', 'text');
149                 $("#newpassword2").val(password);
150                 $("#newpassword2").attr('type', 'text');
151             });
152             $("div.hint").eq(0).after(" <div class=\"hint\"><a href=\"#\" id=\"fillrandom\">"+_("Click to fill with a randomly generated suggestion. ")+"<strong>"+_("Passwords will be displayed as text")+"</strong>.</a></div>");
153
154             $(document).ajaxStart(function () {
155                 $("input[name^=newpassword]").hide();
156                 $("label[for=newpassword2]").hide();
157                 $(".hint:last").after($(".loading").show());
158             });
159             $(document).ajaxStop(function () {
160                 $("input[name^=newpassword]").show();
161                 $("label[for=newpassword2]").show();
162                 $(".loading").hide();
163                 $("label.error").hide();
164             });
165             [% IF NOMATCH %]
166                 $("#newpassword").addClass('focus');
167             [% END %]
168
169             $("#changepasswordf").validate({
170                 rules: {
171                     newpassword: {
172                         password_strong: true,
173                         password_no_spaces: true
174                     },
175                     newpassword2: {
176                         password_match: true
177                     }
178                 }
179             });
180         });
181     </script>
182     [% PROCESS 'password_check.inc' new_password => 'newpassword', minPasswordLength => patron.category.effective_min_password_length, RequireStrongPassword => patron.category.effective_require_strong_password %]
183 [% END %]
184
185 [% INCLUDE 'intranet-bottom.inc' %]