Code

Updated password change for MyAccount
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 2 Jul 2010 07:28:06 +0000 (07:28 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 2 Jul 2010 07:28:06 +0000 (07:28 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18912 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/myaccount/main.inc
gosa-core/plugins/personal/myaccount/password.tpl
gosa-core/plugins/personal/password/class_password.inc

index a69c6ddb9ef6a0e2ef857d324b4d743e53afe8e2..3fcb3ef2640f6b72834a3f6c2142ade275b164fd 100644 (file)
@@ -97,40 +97,15 @@ if (! $cleanup ){
             }
         }
 
-
-        if (isset($_POST['password_finish']) && $MyAccountTabs->password_change_needed){
-            $user = $MyAccountTabs->by_object['user'];
-
-            if ($user->acl_is_writeable("userPassword") || $user->acl_is_createable()){
-                $message= array();
-                if ($_POST['new_password'] != $_POST['repeated_password']){
-                    $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
-                } else {
-                    if ($_POST['new_password'] == ""){
-                        $message[]= msgPool::required(_("New password"));
-                    }
-                }
-
-                if (count($message) != 0){
-                    msg_dialog::displayChecks($message);
-                    $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
-                    return ($display);
-                }
-                change_password ($user->dn, $_POST['new_password'], 0, $user->pw_storage);
-                $MyAccountTabs= new MyAccountTabs($config,$config->data['TABS']['MYACCOUNTTABS'], $ui->dn, "users", true, true);
-                $MyAccountTabs->setReadOnly(TRUE);
-                session::set('MyAccountTabs',$MyAccountTabs);
-                new log("modify","users/password","",array(),"Password has been changed");
-            } else {
-                msg_dialog::display(_("Error"), _("You have no permission to set your password!"), ERROR_DIALOG);
-            }
-
-            del_lock ($ui->dn);
-            session::un_set ('user');
-        }
-
+        // Build up password class to make password-hash changes 
+        //  effective, by setting a new password.
         if($MyAccountTabs->password_change_needed){
-            $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
+            if(!isset($MyAccountTabs->passwordClass)){
+                $user = $MyAccountTabs->by_object['user'];
+                $MyAccountTabs->passwordClass= new password($config, $ui->dn);
+                $MyAccountTabs->passwordClass->forceHash($user->pw_storage);
+            }
+            $display.= $MyAccountTabs->passwordClass->execute();
         }
 
         /* Execute formular */
index 253e513d6c3a3eb8ddaed677c2e240d7b2e3aa70..d5b28604922d633090f93cdbdb2a79dc7f12f7e8 100644 (file)
+<script type="text/javascript" src="include/pwdStrength.js"></script>
+
 <p>
{t}You have changed the method your password is stored in the ldap database. For that reason you've to enter your password at this point again. GOsa will then encode it with the selected method.{/t}
 {t}To change your personal password use the fields below. The changes take effect immediately. Please memorize the new password, because you wouldn't be able to login without it.{/t}
 </p>
 
-<table summary="{t}Password change dialog{/t}" cellpadding=4 border=0>
-  <tr>
-    <td><b><LABEL for="new_password">{t}New password{/t}</LABEL></b></td>
-    <td>
-        {factory type='password' id='new_password' name='new_password' onfocus="nextfield='repeated_password'"}
-  </tr>
-  <tr>
-    <td><b><LABEL for="repeated_password">{t}Repeat new password{/t}</LABEL></b></td>
-    <td>
-        {factory type='password' id='repeated_password' name='repeated_password' onfocus="nextfield='password_finish'"}
-    </td>
-  </tr>
-</table>
+<hr>
+
+{if !$proposalEnabled}
+  <table cellpadding=4 border=0 summary="{t}Password change dialog{/t}">
+    <tr>
+      <td><b><LABEL for="current_password">{t}Current password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='current_password' id='current_password' onfocus="nextfield= 'new_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td><b><LABEL for="new_password">{t}New password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='new_password' id='new_password' 
+              onkeyup="testPasswordCss(\$('new_password').value)"  onfocus="nextfield= 'repeated_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td><b><LABEL for="repeated_password">{t}Repeat new password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='repeated_password' id='repeated_password' onfocus="nextfield= 'password_finish';"}
+      </td>
+    </tr>
+    <tr>
+      <td><b>{t}Password strength{/t}</b></td>
+      <td>
+      <span id="meterEmpty" style="padding:0;margin:0;width:100%;background-color:#DC143C;display:block;height:7px;">
+      <span id="meterFull" style="padding:0;margin:0;z-index:100;width:0;background-color:#006400;display:block;height:7px;"></span></span>
+      </td>
+    </tr>
+  </table>
+{else}
+  <table cellpadding=4 border=0 summary="{t}Password change dialog{/t}">
+    <tr>
+      <td><b><LABEL for="current_password">{t}Current password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='current_password' id='current_password' onfocus="nextfield= 'new_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <input type='radio' value='1' name='proposalSelected'
+            {if $proposalSelected} checked {/if}>&nbsp;<b>{t}Use proposal{/t}</b>
+      </td>
+      <td><b>{$proposal}</b>&nbsp;{image path='images/lists/reload.png' action='refreshProposal'}</td>
+    </tr>
+    <tr>
+      <td>
+        <input type='radio' value='0' name='proposalSelected'
+            {if !$proposalSelected} checked {/if}>&nbsp;<b>{t}Manually specify a password{/t}</b>
+      </td>
+    </tr>
+    <tr>
+      <td style='padding-left:40px;'><b><LABEL for="new_password">{t}New password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='new_password' id='new_password' 
+              onkeyup="testPasswordCss(\$('new_password').value)"  onfocus="nextfield= 'repeated_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td style='padding-left:40px;'><b><LABEL for="repeated_password">{t}Repeat new password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='repeated_password' id='repeated_password' onfocus="nextfield= 'password_finish';"}
+      </td>
+    </tr>
+    <tr>
+      <td  style='padding-left:40px;'><b>{t}Password strength{/t}</b></td>
+      <td>
+      <span id="meterEmpty" style="padding:0;margin:0;width:100%;background-color:#DC143C;display:block;height:7px;">
+      <span id="meterFull" style="padding:0;margin:0;z-index:100;width:0;background-color:#006400;display:block;height:7px;"></span></span>
+      </td>
+    </tr>
+  </table>
+{/if}
 <br>
 
 <hr>
 <div class="plugin-actions">
-  <button type='submit' id='password_finish'name='password_finish'>{t}Set password{/t}</button>
-  <button type='submit' id='password_cancel'name='password_cancel'>{msgPool type=cancelButton}</button>
+  <button type='submit' name='password_finish'>{t}Set password{/t}</button>
+  <button type=reset id="password_cancel" name="password_cancel">{t}Clear fields{/t}</button>
 </div>
 
+<input type='hidden' id='formSubmit'>
+
+<input type="hidden" name="ignore">
+
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page
-       nextfield= "new_password";
-       focus_field('new_password');
+  nextfield= 'current_password';
+       focus_field('current_password');
   -->
 </script>
+
index b15797a369db45c27f9cad6f990f6cb8e0def396..d72adf268c09c9c883c23e7b3fc783da1d502ff6 100644 (file)
@@ -30,6 +30,8 @@ class password extends plugin
     var $proposalEnabled = FALSE;
     var $proposalSelected = FALSE;
 
+    var $forcedHash = NULL;
+
     function password(&$config, $dn= NULL, $parent= NULL)
     {
         plugin::plugin($config, $dn, $parent);
@@ -42,6 +44,12 @@ class password extends plugin
         }
     }
 
+    
+    function forceHash($hash)
+    {
+        $this->forcedHash = $hash;
+    }    
+
 
     function refreshProposal()
     {
@@ -155,7 +163,7 @@ class password extends plugin
                         msg_dialog::display(_("Password change"),
                                 _("You have no permission to change your password."),WARNING_DIALOG);
                     }else{
-                        $this->change_password($ui->dn, $new_password);
+                        $this->change_password($ui->dn, $new_password, $this->forcedHash);
                         gosa_log ("User/password has been changed");
                         $ui->password= $new_password;
                         session::set('ui',$ui);
@@ -168,9 +176,13 @@ class password extends plugin
         return($smarty->fetch(get_template_path("password.tpl", TRUE)));
     } 
 
-    function change_password($dn, $pwd)
+    function change_password($dn, $pwd, $hash)
     {
-        change_password ($dn, $pwd);
+        if(!$hash){
+            change_password ($dn, $pwd);
+        }else{
+            change_password ($dn, $pwd,0, $hash);
+        }
     }
 
     function remove_from_parent()