Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 9d3751c

Browse files
committed
BUG: refs #340 #444. Don't change first/last name display when updating profile
We were changing this data assuming that we were changing our own profile, but admins could be changing the profile of someone else. Users will see the change when they refresh the page or navigate to a new page.
1 parent 72f3077 commit 9d3751c

File tree

1 file changed

+52
-53
lines changed

1 file changed

+52
-53
lines changed

core/public/js/user/user.settings.js

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,106 +3,105 @@ $( "#tabsSettings" ).tabs();
33
$( "#tabsSettings" ).css('display','block');
44
$( "#tabsSettings" ).show();
55

6-
$('#modifyPassword').ajaxForm( { beforeSubmit: validatePasswordChange, success: successPasswordChange } );
6+
$('#modifyPassword').ajaxForm( { beforeSubmit: validatePasswordChange, success: successPasswordChange } );
77

8-
$('#modifyAccount').ajaxForm( { beforeSubmit: validateAccountChange, success: successAccountChange } );
8+
$('#modifyAccount').ajaxForm( { beforeSubmit: validateAccountChange, success: successAccountChange } );
99

10-
$('#modifyPicture').ajaxForm( { beforeSubmit: validatePictureChange, success: successPictureChange } );
10+
$('#modifyPicture').ajaxForm( { beforeSubmit: validatePictureChange, success: successPictureChange } );
1111

1212
jsonSettings = jQuery.parseJSON($('div.jsonSettingsContent').html());
1313

1414
$('textarea#biography').attr('onkeyup', 'this.value = this.value.slice(0, 255)');
1515
$('textarea#biography').attr('onchange', 'this.value = this.value.slice(0, 255)');
1616

1717

18-
function validatePasswordChange(formData, jqForm, options) {
19-
20-
var form = jqForm[0];
21-
if (form.newPassword.value.length<2)
22-
{
23-
createNotive(jsonSettings.passwordErrorShort,4000);
24-
return false;
25-
}
26-
if (form.newPassword.value.length<2||form.newPassword.value != form.newPasswordConfirmation.value) {
27-
createNotive(jsonSettings.passwordErrorMatch,4000);
28-
return false;
18+
function validatePasswordChange(formData, jqForm, options)
19+
{
20+
var form = jqForm[0];
21+
if(form.newPassword.value.length < 2)
22+
{
23+
createNotice(jsonSettings.passwordErrorShort, 4000);
24+
return false;
25+
}
26+
if(form.newPassword.value.length < 2 || form.newPassword.value != form.newPasswordConfirmation.value)
27+
{
28+
createNotice(jsonSettings.passwordErrorMatch, 4000);
29+
return false;
2930
}
3031
}
3132

32-
function validatePictureChange(formData, jqForm, options) {
33-
34-
var form = jqForm[0];
35-
33+
function validatePictureChange(formData, jqForm, options)
34+
{
35+
var form = jqForm[0];
3636
}
3737

38-
function validateAccountChange(formData, jqForm, options) {
39-
40-
var form = jqForm[0];
41-
if (form.firstname.value.length<1)
42-
{
43-
createNotive(jsonSettings.accountErrorFirstname,4000);
44-
return false;
45-
}
46-
if (form.lastname.value.length<1)
47-
{
48-
createNotive(jsonSettings.accountErrorLastname,4000);
49-
return false;
50-
}
38+
function validateAccountChange(formData, jqForm, options)
39+
{
40+
var form = jqForm[0];
41+
if(form.firstname.value.length < 1)
42+
{
43+
createNotice(jsonSettings.accountErrorFirstname, 4000);
44+
return false;
45+
}
46+
if(form.lastname.value.length < 1)
47+
{
48+
createNotice(jsonSettings.accountErrorLastname, 4000);
49+
return false;
50+
}
5151
}
5252

53-
function successPasswordChange(responseText, statusText, xhr, $form)
53+
function successPasswordChange(responseText, statusText, xhr, form)
5454
{
5555
jsonResponse = jQuery.parseJSON(responseText);
56-
if(jsonResponse==null)
56+
if(jsonResponse == null)
5757
{
58-
createNotive('Error',4000);
59-
return;
58+
createNotice('Error', 4000);
59+
return;
6060
}
6161
if(jsonResponse[0])
6262
{
63-
createNotive(jsonResponse[1],4000);
63+
createNotice(jsonResponse[1], 4000);
6464
}
6565
else
6666
{
67-
$('#modifyPassword input[type=password]').val('');
68-
createNotive(jsonResponse[1],4000);
67+
$('#modifyPassword input[type=password]').val('');
68+
createNotice(jsonResponse[1], 4000);
6969
}
7070
}
7171

72-
function successAccountChange(responseText, statusText, xhr, $form)
72+
function successAccountChange(responseText, statusText, xhr, form)
7373
{
7474
jsonResponse = jQuery.parseJSON(responseText);
75-
if(jsonResponse==null)
75+
if(jsonResponse == null)
7676
{
77-
createNotive('Error',4000);
78-
return;
77+
createNotice('Error', 4000);
78+
return;
7979
}
8080
if(jsonResponse[0])
8181
{
82-
$('a#topUserName').html($('#modifyAccount input[name=firstname]').val()+' '+$('#modifyAccount input[name=lastname]').val()+' <img class="arrowUser" src="'+json.global.coreWebroot+'/public/images/icons/arrow-user.gif" alt ="" />');
83-
createNotive(jsonResponse[1],4000);
82+
createNotice(jsonResponse[1], 4000);
8483
}
8584
else
8685
{
87-
createNotive(jsonResponse[1],4000);
86+
createNotice(jsonResponse[1], 4000);
8887
}
8988
}
9089

91-
function successPictureChange(responseText, statusText, xhr, $form)
90+
function successPictureChange(responseText, statusText, xhr, form)
9291
{
9392
jsonResponse = jQuery.parseJSON(responseText);
94-
if(jsonResponse==null)
93+
if(jsonResponse == null)
9594
{
96-
createNotive('Error',4000);
97-
return;
95+
createNotice('Error', 4000);
96+
return;
9897
}
9998
if(jsonResponse[0])
10099
{
101-
$('img#userTopThumbnail').attr('src', jsonResponse[2]);
102-
createNotive(jsonResponse[1],4000);
100+
$('img#userTopThumbnail').attr('src', jsonResponse[2]);
101+
createNotice(jsonResponse[1], 4000);
103102
}
104103
else
105104
{
106-
createNotive(jsonResponse[1],4000);
105+
createNotice(jsonResponse[1], 4000);
107106
}
108-
}
107+
}

0 commit comments

Comments
 (0)