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