Bug 26266: Add jQuery validator to opac-password-recovery.tt
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-password-recovery.tt
1 [% USE Koha %]
2 [% USE Categories %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Forgotten password recovery</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 [% BLOCK cssinclude %][% END %]
7 [% BLOCK jsinclude %]
8 [% IF (new_password) %]
9     [% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
10     [% PROCESS 'password_check.inc' new_password => 'newPassword', minPasswordLength => minPasswordLength, RequireStrongPassword => RequireStrongPassword %]
11 [% END %]
12     <script>
13     $(function() {
14             $("#CheckAll").click(function(){
15                     $("[name=deleteRequest]").attr('checked', true);
16                     return false;
17                 });
18
19             $("#CheckNone").click(function(){
20                     $("[name=deleteRequest]").attr('checked', false);
21                     return false;
22                 });
23
24             $("select#type").change(function() {
25                 $("fieldset#serial, fieldset#book, fieldset#chapter").hide()
26                 $("fieldset#" + $(this).val() ).show();
27             });
28         [% IF (new_password) %]
29             $("#mainform").validate({
30                 rules: {
31                     newPassword: {
32                         required: true,
33                         password_strong: true,
34                         password_no_spaces: true
35                     },
36                     repeatPassword: {
37                         required: true,
38                         password_match: true
39                     }
40                 }
41             });
42         [% END %]
43     });
44     </script>
45 [% END %]
46 </head>
47 [% INCLUDE 'bodytag.inc' bodyid='opac-password-recovery' %]
48 [% INCLUDE 'masthead.inc' %]
49
50 <div class="main">
51     <nav aria-label="breadcrumb">
52         <ul class="breadcrumb">
53             <li class="breadcrumb-item">
54                 <a href="/cgi-bin/koha/opac-main.pl">Home</a>
55             </li>
56             <li class="breadcrumb-item" aria-current="page">
57                 <a href="#">Forgotten password recovery</a>
58             </li>
59         </ul>
60     </nav>
61
62     <div class="container-fluid">
63         <div class="row">
64             <div class="col-lg-2">
65                 [% IF ( OpacPublic ) %]
66                     <div id="navigation">
67                         [% INCLUDE 'navigation.inc' IsPatronPage=0 %]
68                     </div>
69                 [% END %]
70             </div>
71             <div class="col-6 order-first order-md-first order-lg-2 maincontent">
72                 <h3>Forgotten password recovery</h3>
73                 [% IF (hasError) %]
74                     <div class="alert alert-warning">
75                         <h3>Error</h3>
76                         <p>
77                         [% IF (sendmailError) %]
78                             An error has occurred while sending you the password recovery link.
79                             <br/>Please try again later.
80                         [% ELSIF (errNoBorrowerFound) %]
81                             No account was found with the provided information.
82                         [% ELSIF errResetForbidden %]
83                             <span id="password-reset-forbidden">Sorry, your password cannot be changed online.</span>
84                         [% ELSIF (errMultipleAccountsForEmail) %]
85                             Account identification with this email address only is ambiguous.
86                             <br />Please use the field 'Login' as well.
87                         [% ELSIF (errAlreadyStartRecovery) %]
88                             The process of password recovery has already been started for this account
89                             [% IF username %]
90                                 ("<strong>[% username | html %]</strong>")
91                             [% ELSIF email %]
92                                 ("<strong>[% email | html %]</strong>")
93                             [% END %]
94                             <br/>You should have received an email with a link to reset your password.
95                             <br/>If you did not receive this email, you can request a new one: <a href="/cgi-bin/koha/opac-password-recovery.pl?resendEmail=true&email=[% email | uri %]&username=[% username | uri %]">Get new password recovery link</a>
96                         [% ELSIF (errPassNotMatch) %]
97                             The passwords do not match.
98                         [% ELSIF password_too_short %]
99                             <li>Password must be at least [% minPasswordLength | html %] characters long.</li>
100                         [% ELSIF password_too_weak %]
101                             <li>Password must contain at least one digit, one lowercase and one uppercase.</li>
102                         [% ELSIF password_has_whitespaces %]
103                             <li>Password must not contain leading or trailing whitespaces.</li>
104                         [% ELSIF (errLinkNotValid) %]
105                             The link you clicked is either invalid, or expired.
106                             <br/>Be sure you used the link from the email, or contact library staff for assistance.
107                         [% END %]
108                         </p>
109                         <p>Please contact the library if you need further assistance.</p>
110                     </div> <!-- /div.alert.alert-warning -->
111                 [% END # /IF hasError %]
112
113                 <div id="password-recovery">
114                     [% IF (! Categories.can_any_reset_password ) %]
115                         <div class="alert alert-info">You can't reset your password.</div>
116                     [% ELSIF (password_recovery) %]
117                         <form action="/cgi-bin/koha/opac-password-recovery.pl" method="post" autocomplete="off">
118                             <input type="hidden" name="koha_login_context" value="opac" />
119                             <p>To reset your password, enter your login or your email address.</p>
120                             <fieldset class="brief">
121                                 <div class="form-group">
122                                     <label for="username">Login:</label>
123                                     <input class="form-control" type="text" id="username" size="40" name="username" value="[% username | html %]" />
124                                 </div>
125
126                                 <div class="form-group">
127                                     <label for="email">Email:</label>
128                                     <input class="form-control" type="text" id="email" size="40" name="email" value="[% email | html %]" />
129                                 </div>
130
131                                 <fieldset class="action">
132                                     <input type="submit" value="Submit" class="btn btn-primary" name="sendEmail" />
133                                 </fieldset>
134                             </fieldset>
135                         </form>
136                     [% ELSIF (new_password) %]
137                         [% UNLESS ( errLinkNotValid ) %]
138                             <form id="mainform" name="mainform" action="/cgi-bin/koha/opac-password-recovery.pl" method="post" autocomplete="off">
139                                 <input type="hidden" name="koha_login_context" value="opac" />
140                                 <fieldset class="brief">
141                                     [% IF ( RequireStrongPassword ) %]
142                                         <div class="alert alert-info">Your password must contain at least [% minPasswordLength | html %] characters, including UPPERCASE, lowercase and numbers.</div>
143                                     [% ELSE %]
144                                         <div class="alert alert-info">Your password must be at least [% minPasswordLength | html %] characters long.</div>
145                                     [% END %]
146                                     <div class="form-group">
147                                         <label for="newPassword">New password:</label>
148                                         <input class="form-control" type="password" id="newPassword" size="40" name="newPassword" />
149                                     </div>
150
151                                     <div class="form-group">
152                                         <label for="repeatPassword">Confirm new password:</label>
153                                         <input class="form-control" type="password" id="repeatPassword" size="40" name="repeatPassword" />
154                                     </div>
155
156                                     <fieldset class="action">
157                                         <input type="hidden" name="username" value="[% username | html %]" />
158                                         <input type="hidden" name="uniqueKey" value="[% uniqueKey | html %]" />
159                                         <input type="submit" value="Submit" class="btn btn-primary" name="passwordReset" />
160                                     </fieldset>
161                                 </fieldset>
162                             </form>
163                         [% END # /UNLESS errLinkNotValid %]
164                     [% ELSIF (mail_sent) %]
165                         <div class="alert alert-info">
166                             <p>
167                                 You will receive an email shortly.
168                                 <br/>Please click the link in this email to finish the process of resetting your password.
169                                 <br/>This link is valid for 2 days starting now.
170                             </p>
171                             <a href="/cgi-bin/koha/opac-main.pl">Return to the main page</a>
172                         </div>
173                     [% ELSIF (password_reset_done) %]
174                         <div class="alert alert-success">
175                             <p>The password has been changed for user "[% username | html %]".</p>
176                             <a href="/cgi-bin/koha/opac-user.pl">Click here to login.</a>
177                         </div>
178                     [% END # /IF (! Categories.can_any_reset_password ) %]
179                 </div><!-- / #password-recovery -->
180             </div><!-- / .span10 -->
181         </div><!-- / .row-fluid -->
182     </div><!-- / .container-fluid -->
183 </div><!-- / .main -->
184 [% INCLUDE 'opac-bottom.inc' %]