Skip to content

Commit aa57885

Browse files
author
Topi Paavilainen
committed
error message for incorrect new password (too close to username or old password)
1 parent 391102b commit aa57885

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

fum/api/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ def password(self, request, username=None, relname=None):
323323
user.set_ldap_password(password)
324324
return Response("Ok", status=200)
325325
except Exception, e:
326-
return Response("Fail: %s"%e, status=500)
326+
return Response("New password too similar to the username or to an old password", status=403)
327327
else:
328-
return Response("Old password fail", status=403)
328+
return Response("Incorrect old password", status=403)
329329

330330
# TODO: Faster failing option: try to first write to ldap, only then save the image files to disk?
331331
@action(methods=['post'])

fum/common/static/js/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ $(document).ready(function(){
108108
$('#password-new, #password-new-again, #password-current').val('');
109109
$('#password-status, #password-status-again').html('');
110110
$('#password-new-again').change();
111+
$('#wrong-password-alert').hide();
111112
});
112113
/* validations */
113114
$('#password-new').bind("change paste keyup", function() {
114115
if(!validatePasswordLength($(this).val())){
115-
console.log("green");
116116
$('#password-length').show();
117117
}else{
118118
$('#password-length').hide();
@@ -127,7 +127,6 @@ $(document).ready(function(){
127127

128128
$('#password-new-again').bind("change paste keyup", function() {
129129
if ($(this).val() === $('#password-new').val() && $(this).val().length > 0) {
130-
console.log("jaahas");
131130
$('#passwords-matching').hide();
132131
if (validatePassword($('#password-new').val())) {
133132
$('#password-change').removeClass('btn-warning').addClass('btn-success').removeAttr('disabled');
@@ -146,7 +145,10 @@ $(document).ready(function(){
146145
if ($('#password-new').val() === $('#password-new-again').val() && validatePassword($('#password-new').val())) {
147146
$.post($(this).attr('data-url'), { 'password': $('#password-new').val(), 'old_password': $('#password-current').val() || "" })
148147
.done(function() { $('#password-cancel').click(); })
149-
.fail(function(data) { $('#wrong-password-alert').show(); });
148+
.fail(function(data) {
149+
$('#wrong-password-alert').html(data.responseText.replace(/\"/g, ""));
150+
$('#wrong-password-alert').show();
151+
});
150152
} else {
151153
return;
152154
}

fum/users/templates/users/users_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ <h3>Change password{% if sudo %} (for user {{object.username}}) {% endif %}</h3>
181181
{% if sudo %}
182182
<a href="{% url "users-changepassword" object.username %}" id="sudo_change_password">SUDO: Change to a random password and send it via SMS</a>
183183
{% endif %}
184-
<div id="wrong-password-alert" class="alert alert-danger" style="display:none;">Incorrect current password</div>
184+
<div id="wrong-password-alert" class="alert alert-danger" style="display:none;"></div>
185185
<div id="password-length" class="alert alert-info">Password must be at least 10 characters long</div>
186186
<div id="password-character-groups" class="alert alert-info">Password must have characters from at least 3 character groups (a-z, A-Z, 0-9, special)</div>
187187
<div id="passwords-matching" class="alert alert-info" style="display:none;">Passwords don't match</div>

0 commit comments

Comments
 (0)