On 10/15/2010 03:23 PM, Adam Young wrote:
On 10/15/2010 03:05 PM, Adam Young wrote:


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel
Just realized that there is a bug in here. If the admin runs this, he will change his own password. As written, it only works for self service. I'll update shortly.


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Now check the principal prior to calling passwd, and add that as a parameter for non-selfservice case.
From 7e4e551bd1b19545c5633ae933bae190016caea3 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 15 Oct 2010 14:06:23 -0400
Subject: [PATCH] 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.

---
 install/static/ipa.css  |   24 ++++++++++++++++++
 install/static/user.js  |   63 ++++++++++++++++++++++++++++++++++++++++++++--
 install/static/webui.js |   11 +++++---
 3 files changed, 91 insertions(+), 7 deletions(-)

diff --git a/install/static/ipa.css b/install/static/ipa.css
index eb5396d..708cbae 100644
--- a/install/static/ipa.css
+++ b/install/static/ipa.css
@@ -277,3 +277,27 @@ span.main-separator{
 }
 
 .strikethrough { text-decoration: line-through; }
+
+
+
+dl.modal {
+    clear: both;
+    margin-left: 15px;
+    margin-top: 18px;
+    white-space: nowrap;
+}
+
+dl.modal dt {
+    clear: left;
+    float: left;
+    padding-bottom: 0px;
+    padding-right: 0px;
+    text-align: right;
+    width: 150px;
+}
+
+dl.modal dd {
+    float: left;
+    padding-bottom: 0px;
+    margin-left: 10px;
+}
diff --git a/install/static/user.js b/install/static/user.js
index e651d24..926cdf0 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>';
diff --git a/install/static/webui.js b/install/static/webui.js
index a53824b..60ccc25 100644
--- a/install/static/webui.js
+++ b/install/static/webui.js
@@ -52,19 +52,22 @@ var self_serv_tab_set =
         { name:'identity', label:'IDENTITY', children: [
             {name:'user', label:'Users', setup:ipa_entity_setup}]}];
 
+
+var ipa_whoami_pkey;
+
+
 /* main (document onready event handler) */
 $(function() {
 
-    var whoami_pkey;
 
     function whoami_on_win(data, text_status, xhr) {
         $(window).bind('hashchange', window_hashchange);
         if (!data.error){
             var whoami = data.result.result[0];
-            whoami_pkey=whoami.uid[0];
+            ipa_whoami_pkey=whoami.uid[0];
             $('#loggedinas').find('strong').text(whoami.krbprincipalname[0]);
             $('#loggedinas a').fragment(
-                {'user-facet':'details', 'user-pkey':whoami_pkey},2);
+                {'user-facet':'details', 'user-pkey':ipa_whoami_pkey},2);
 
             var navigation = $('#navigation');
 
@@ -75,7 +78,7 @@ $(function() {
             }else{
                 nav_create(self_serv_tab_set, navigation, 'tabs');
 
-                var state = {'user-pkey':whoami_pkey ,
+                var state = {'user-pkey':ipa_whoami_pkey ,
                              'user-facet': jQuery.bbq.getState('user-facet') ||
                              'details'};
                 $.bbq.pushState(state);
-- 
1.7.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to