summaryrefslogtreecommitdiffstats
path: root/template/en/default/account/reset-password.html.tmpl
blob: 2b1d297dcfe7ff55b65391278544d50ea9c53e13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[% inline_style = BLOCK %]

.field-hr, .field-row {
  clear: both;
}

.field-row {
  height: 2.5em;
}

.field-name {
  text-align: right;
  width: 150px;
  float: left;
  padding-top: 2px;
  font-weight: bold;
}

.field-value {
  margin-left: 160px;
}

#errors, #complexity_rules {
  margin-left: 160px;
  max-width: 500px;
}

#errors {
  color: #dd4848;
  position: absolute;
  margin-left: 500px;
}

#errors ul {
  padding: 0;
  margin: 0;
}

#complexity_rules {
  margin-bottom: 50px;
}

[% END %]

[% inline_js = BLOCK %]
$(function() {

  $('#old_password, #new_password1, #new_password2')
    .keyup(function() {
      var errors = [];
      var old = $('#old_password').val();
      var new1 = $('#new_password1').val();
      var new2 = $('#new_password2').val();

      if (old === '') {
        errors.push('Missing current password');
      }
      if (new1 === '' || new2 === '') {
        errors.push('Missing new password');
      }
      else if (new1 !== new2) {
        errors.push('New passwords do not match');
      }
      else if (new1 === old) {
        errors.push('Your new password must be different from your old password');
      }
      else if (new1.length < [% constants.USER_PASSWORD_MIN_LENGTH FILTER none %]) {
        errors.push('Your password must be at least [% constants.USER_PASSWORD_MIN_LENGTH FILTER none %] long');
      }
      else {
        var complexity_fn;
        [% SWITCH Param('password_complexity') %]
          [% CASE 'no_constraints' %]
            complexity_fn = function() {};
          [% CASE 'mixed_letters' %]
            complexity_fn = function(pass, errors) {
              if (
                pass.search(/[a-z]/) == -1 ||
                pass.search(/[A-Z]/) == -1
              ) {
                errors.push('New password is not complex enough');
              }
            };
          [% CASE 'letters_numbers' %]
            complexity_fn = function(pass, errors) {
              if (
                pass.search(/[a-z]/) == -1 ||
                pass.search(/[A-Z]/) == -1 ||
                pass.search(/[0-9]/) == -1
              ) {
                errors.push('New password is not complex enough');
              }
            };
          [% CASE 'letters_numbers_specialchars' %]
            complexity_fn = function(pass, errors) {
              if (
                pass.search(/[a-z]/) == -1 ||
                pass.search(/[A-Z]/) == -1 ||
                pass.search(/[0-9]/) == -1 ||
                pass.search(/\W/) == -1
              ) {
                errors.push('New password is not complex enough');
              }
            };
        [% END %]
        complexity_fn(new1, errors);
      }

      $('#submit').attr('disabled', errors.length > 0);
      if ((old !== '' || new1 !== '' || new2 !== '') && errors.length) {
        $('#errors').html('<ul><li>' + errors.join('</li><li>') + '</li></ul>');
      }
      else {
        $('#errors').html('');
      }
    })
    .keyup();

  $('#forgot_password')
    .click(function(event) {
      event.preventDefault();
      $('#forgot-form').submit();
    });
});

[% END %]

[% PROCESS global/header.html.tmpl
    title      = "Password change required"
    style      = inline_style
    javascript = inline_js
%]

<h1>Password Reset</h1>

<p>
  [% user.password_change_reason || "You are required to update your password." FILTER html %]
</p>

<form method="POST" action="reset_password.cgi">
<input type="hidden" name="token" value="[% token FILTER html %]">
<input type="hidden" name="do_save" value="1">

<div id="password-reset">
  <div class="field-hr">&nbsp;</div>
  <div class="field-row">
    <div class="field-name">Email</div>
    <div class="field-value">
      [% user.login FILTER html %]
    </div>
  </div>
  <div class="field-row">
    <div class="field-name">Current Password</div>
    <div class="field-value">
      <input type="password" name="old_password" id="old_password" size="30">
    </div>
  </div>
  <div class="field-hr">&nbsp;</div>
  <div id="errors"></div>
  <div class="field-row">
    <div class="field-name">New Password</div>
    <div class="field-value">
      <input type="password" name="new_password1" id="new_password1" size="30">
    </div>
  </div>
  <div class="field-row">
    <div class="field-name">New Password</div>
    <div class="field-value">
      <input type="password" name="new_password2" id="new_password2" size="30">
      (again)
    </div>
  </div>
  <div class="field-hr">&nbsp;</div>
  <div class="field-row">
    <div class="field-value">
      <input type="submit" id="submit" value="Update Password">
      <a id="forgot_password" href="#">Forgot Password</a>
    </div>
  </div>
</div>

</form>

<p id="complexity_rules">
  Your password must be a minimum of [% constants.USER_PASSWORD_MIN_LENGTH FILTER none %] characters long
  [% SWITCH Param('password_complexity') %]
    [% CASE 'mixed_letters' %]
      and must contain at least one UPPER and one lowercase letter
    [% CASE 'letters_numbers' %]
      and must contain at least one UPPER and one lowercase letter and a number
    [% CASE 'letters_numbers_specialchars' %]
      and must contain at least one letter, a number and a special character
  [% END ~%].
</p>

<form action="token.cgi" method="post" id="forgot-form">
  <input type="hidden" name="loginname" value="[% user.login FILTER html %]">
  <input type="hidden" name="a" value="reqpw">
  <input type="hidden" name="token" value="[% issue_hash_token(['reqpw']) FILTER html %]">
</form>

[% PROCESS global/footer.html.tmpl %]