diff options
author | Adam Young <ayoung@redhat.com> | 2010-10-15 14:06:23 -0400 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2010-10-20 10:54:51 -0400 |
commit | 4f7f40004361d9a63f625e5e70d0969c41d43958 (patch) | |
tree | 59314d10c4ae371c500491e9c740570cb08ad33b /install/static/user.js | |
parent | 2c5f3cfd60575d7c72e6be8124b34c88b90d9fb7 (diff) | |
download | freeipa-4f7f40004361d9a63f625e5e70d0969c41d43958.tar.gz freeipa-4f7f40004361d9a63f625e5e70d0969c41d43958.tar.xz freeipa-4f7f40004361d9a63f625e5e70d0969c41d43958.zip |
password dialog
added a modal dialog for resetting the password.
Made the whoami varaible global, as anything dependant on the principal will require access to it.
Diffstat (limited to 'install/static/user.js')
-rw-r--r-- | install/static/user.js | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/install/static/user.js b/install/static/user.js index e651d242c..926cdf00a 100644 --- a/install/static/user.js +++ b/install/static/user.js @@ -171,11 +171,68 @@ function user_status_load(container, dt, result) dt.after(dd); } -var pwd_temp = '<a href="jslink" onclick="return (resetpwd_on_click(this))" title="A">Reset Password</a>'; + + +function resetpwd_on_click(){ + + function reset_password(new_password){ + var dialog = resetpwd_dialog; + + var user_pkey = $.bbq.getState('user-pkey'); + var pw_pkey; + if (user_pkey === ipa_whoami_pkey){ + pw_pkey = []; + }else{ + pw_pkey = [user_pkey]; + } + + ipa_cmd('passwd', + pw_pkey, {"password":new_password}, + function(){ + alert("Password change complete"); + dialog.dialog("close"); + }, + function(){}); + } + + + var resetpwd_dialog = + $('<div ><dl class="modal">'+ + '<dt>New Password</dt>'+ + '<dd class="first" ><input id="password_1" type="password"/></dd>'+ + '<dt>Repeat Password</dt>'+ + '<dd class="first"><input id="password_2" type="password"/></dd>'+ + '</dl></div>'); + resetpwd_dialog.dialog( + { modal: true, + minWidth:400, + buttons: { + 'Reset Password': function(){ + var p1 = $("#password_1").val(); + var p2 = $("#password_2").val(); + if (p1 != p2){ + alert("passwords must match"); + return; + } + reset_password(p1); + }, + 'Cancel':function(){ + resetpwd_dialog.dialog('close'); + } + }}); + return false; +} + function user_password_load(container, dt, result) { - var dd = ipa_create_first_dd(this.name, pwd_temp.replace('A', 'userpassword')); - dt.after(dd); + dt.after(ipa_create_first_dd( + this.name, + $('<a/>',{ + href:"jslink", + click:resetpwd_on_click, + title:'userpassword', + text: 'reset password' + }))); } var select_temp = '<select title="st"></select>'; |