From 978d13bc255758e847acd17da1bc91b797e9cf63 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 2 Jul 2010 07:28:06 +0000 Subject: [PATCH] Updated password change for MyAccount git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18912 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/plugins/personal/myaccount/main.inc | 41 ++----- .../plugins/personal/myaccount/password.tpl | 104 +++++++++++++++--- .../personal/password/class_password.inc | 18 ++- 3 files changed, 109 insertions(+), 54 deletions(-) diff --git a/gosa-core/plugins/personal/myaccount/main.inc b/gosa-core/plugins/personal/myaccount/main.inc index a69c6ddb9..3fcb3ef26 100644 --- a/gosa-core/plugins/personal/myaccount/main.inc +++ b/gosa-core/plugins/personal/myaccount/main.inc @@ -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 */ diff --git a/gosa-core/plugins/personal/myaccount/password.tpl b/gosa-core/plugins/personal/myaccount/password.tpl index 253e513d6..d5b286049 100644 --- a/gosa-core/plugins/personal/myaccount/password.tpl +++ b/gosa-core/plugins/personal/myaccount/password.tpl @@ -1,32 +1,100 @@ + +

- {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}

- - - - - - - - -
- {factory type='password' id='new_password' name='new_password' onfocus="nextfield='repeated_password'"} -
- {factory type='password' id='repeated_password' name='repeated_password' onfocus="nextfield='password_finish'"} -
+
+ +{if !$proposalEnabled} + + + + + + + + + + + + + + + + + +
+ {factory type='password' name='current_password' id='current_password' onfocus="nextfield= 'new_password';"} +
+ {factory type='password' name='new_password' id='new_password' + onkeyup="testPasswordCss(\$('new_password').value)" onfocus="nextfield= 'repeated_password';"} +
+ {factory type='password' name='repeated_password' id='repeated_password' onfocus="nextfield= 'password_finish';"} +
{t}Password strength{/t} + + +
+{else} + + + + + + + + + + + + + + + + + + + + + + + + +
+ {factory type='password' name='current_password' id='current_password' onfocus="nextfield= 'new_password';"} +
+  {t}Use proposal{/t} + {$proposal} {image path='images/lists/reload.png' action='refreshProposal'}
+  {t}Manually specify a password{/t} +
+ {factory type='password' name='new_password' id='new_password' + onkeyup="testPasswordCss(\$('new_password').value)" onfocus="nextfield= 'repeated_password';"} +
+ {factory type='password' name='repeated_password' id='repeated_password' onfocus="nextfield= 'password_finish';"} +
{t}Password strength{/t} + + +
+{/if}

- - + +
+ + + + + diff --git a/gosa-core/plugins/personal/password/class_password.inc b/gosa-core/plugins/personal/password/class_password.inc index b15797a36..d72adf268 100644 --- a/gosa-core/plugins/personal/password/class_password.inc +++ b/gosa-core/plugins/personal/password/class_password.inc @@ -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() -- 2.30.2