summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-03-04 14:32:50 -0600
committerAdam Young <ayoung@redhat.com>2011-03-04 16:39:07 -0500
commit6fc488e12fdf45ae67439dc9883e78eb07cc4113 (patch)
tree76f1d7777cd6a63440e4e444a933cac71ec0275f
parent8b041cd1a359b0a3496c16abbc6a32c804084d83 (diff)
downloadfreeipa-6fc488e12fdf45ae67439dc9883e78eb07cc4113.zip
freeipa-6fc488e12fdf45ae67439dc9883e78eb07cc4113.tar.gz
freeipa-6fc488e12fdf45ae67439dc9883e78eb07cc4113.tar.xz
Fixed memory leak caused by reset password dialog.
Ticket 1054
-rw-r--r--install/ui/user.js117
1 files changed, 75 insertions, 42 deletions
diff --git a/install/ui/user.js b/install/ui/user.js
index e098ad1..8e1cb3f 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -171,68 +171,101 @@ IPA.user_password_widget = function(spec) {
var that = IPA.widget(spec);
that.create = function(container) {
+
$('<a/>', {
href: 'jslink',
title: 'userpassword',
text: IPA.messages.objects.user.reset_password,
- click: resetpwd_on_click
+ click: function() {
+ that.show_dialog();
+ return false;
+ }
}).appendTo(container);
};
- function resetpwd_on_click() {
+ that.show_dialog = function() {
- function reset_password(new_password) {
+ var dialog = IPA.dialog({
+ title: IPA.messages.objects.user.reset_password,
+ width: 400
+ });
- var user_pkey = $.bbq.getState('user-pkey');
- var pw_pkey;
- if (user_pkey === IPA.whoami.uid[0]){
- pw_pkey = [];
- }else{
- pw_pkey = [user_pkey];
- }
+ dialog.create = function() {
- IPA.cmd('passwd',
- pw_pkey, {"password":new_password},
- function(){
- alert(IPA.messages.objects.user.password_change_complete);
- dialog.dialog("close");
- },
- function(){});
- }
+ var dl = $('<dl/>', {
+ 'class': 'modal'
+ }).appendTo(dialog.container);
+
+ $('<dt/>', {
+ html: IPA.messages.objects.user.new_password
+ }).appendTo(dl);
+
+ var dd = $('<dd/>', {
+ 'class': 'first'
+ }).appendTo(dl);
+
+ dialog.password1 = $('<input/>', {
+ type: 'password'
+ }).appendTo(dd);
+
+ $('<dt/>', {
+ html: IPA.messages.objects.user.repeat_password
+ }).appendTo(dl);
+
+ dd = $('<dd/>', {
+ 'class': 'first'
+ }).appendTo(dl);
- var dialog =
- $('<div ><dl class="modal">'+
- '<dt>'+IPA.messages.objects.user.new_password+'</dt>'+
- '<dd class="first" ><input id="password_1" type="password"/></dd>'+
- '<dt>'+IPA.messages.objects.user.repeat_password+'</dt>'+
- '<dd class="first"><input id="password_2" type="password"/></dd>'+
- '</dl></div>');
+ dialog.password2 = $('<input/>', {
+ type: 'password'
+ }).appendTo(dd);
+ };
+
+ dialog.add_button(IPA.messages.objects.user.reset_password, function() {
- var buttons = {};
+ var new_password = dialog.password1.val();
+ var repeat_password = dialog.password2.val();
- buttons[IPA.messages.objects.user.reset_password] = function() {
- var p1 = $("#password_1").val();
- var p2 = $("#password_2").val();
- if (p1 != p2) {
+ if (new_password != repeat_password) {
alert(IPA.messages.objects.user.password_must_match);
return;
}
- reset_password(p1);
- };
- buttons[IPA.messages.buttons.cancel] = function() {
- dialog.dialog('close');
- };
+ var user_pkey = $.bbq.getState('user-pkey');
- dialog.dialog({
- modal: true,
- title: IPA.messages.objects.user.reset_password,
- minWidth: 400,
- buttons: buttons
+ var args;
+ if (user_pkey === IPA.whoami.uid[0]) {
+ args = [];
+ } else {
+ args = [user_pkey];
+ }
+
+ var command = IPA.command({
+ method: 'passwd',
+ args: args,
+ options: {
+ password: new_password
+ },
+ on_success: function(data, text_status, xhr) {
+ alert(IPA.messages.objects.user.password_change_complete);
+ dialog.close();
+ },
+ on_error: function(xhr, text_status, error_thrown) {
+ dialog.close();
+ }
+ });
+
+ command.execute();
+ });
+
+ dialog.add_button(IPA.messages.buttons.cancel, function() {
+ dialog.close();
});
- return false;
- }
+ dialog.init();
+
+ dialog.open(that.container);
+ };
return that;
};