summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 864b839)
raw | patch | inline | side by side (parent: 864b839)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 10 Jul 2007 13:43:44 +0000 (13:43 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 10 Jul 2007 13:43:44 +0000 (13:43 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6815 594d385d-05f5-0310-b6e9-bd551577e9d8
index b74ea405929ebc30f1f577f3d6823dadcd64ccfe..16db3000168e42ba50756f00b709d1301796b8bf 100644 (file)
+
<p>
<b>{t}You've successfully changed your password. Remember to change all programms configured to use it as well.{/t}</b>
</p>
diff --git a/plugins/personal/password/class_password.inc b/plugins/personal/password/class_password.inc
index 46cf8a0488813481f93d6434bc130684e55e70e7..df80924b8f7cb4fd0261661d1fcfb78caec126a5 100644 (file)
<?php
-class password
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2007 Fabian Hickert
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class password extends plugin
{
/* Definitions */
- var $plHeadline= "Password";
- var $plDescription= "This does something";
+ var $plHeadline = "Password";
+ var $plDescription = "This does something";
+
+ function password($config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin($config, $dn, $parent);
+ }
+
+
+ function execute()
+ {
+ plugin::execute();
+ $smarty = get_smarty();
+ $ui = get_userinfo();
+
+ /* Get acls */
+ $password_ACLS = $ui->get_permissions($ui->dn,"users/password");
+ $smarty->assign("ChangeACL" , $password_ACLS);
+ $smarty->assign("NotAllowed" , !preg_match("/w/i",$password_ACLS));
+
+ /* Display expiration template */
+ if((isset($this->config->data['MAIN']['ACCOUNT_EXPIRATION'])) &&
+ preg_match('/true/i', $this->config->data['MAIN']['ACCOUNT_EXPIRATION'])){
+ $expired= ldap_expired_account($this->config, $ui->dn, $ui->username);
+ if($expired == 4){
+ return($smarty->fetch(get_template_path("nochange.tpl", TRUE)));
+ }
+ }
+
+ /* Pwd change requested */
+ if (isset($_POST['password_finish'])){
+
+ /* Should we check different characters in new password */
+ $check_differ = isset($this->config->data['MAIN']['PWDIFFER']);
+ $differ = @$this->config->data['MAIN']['PWDIFFER'];
+
+ /* Enable length check ? */
+ $check_length = isset($this->config->data['MAIN']['PWMINLEN']);
+ $length = @$this->config->data['MAIN']['PWMINLEN'];
+
+ /* Call external password quality hook ?*/
+ $check_hook = isset($this->config->data['MAIN']['EXTERNALPWDHOOK']);
+ $hook = @$this->config->data['MAIN']['EXTERNALPWDHOOK']." ".$ui->username." ".$_POST['current_password']." ".$_POST['new_password'];
+ if($check_hook){
+ exec($hook,$resarr);
+ $check_hook_output = "";
+ if(count($resarr) > 0) {
+ $check_hook_output= join('\n', $resarr);
+ }
+ }
+
+ /* Check given values */
+ if(!isset($_POST['current_password']) || empty($_POST['current_password'])){
+ print_red(_("You need to specify your current password in order to proceed."));
+ }elseif ($_POST['new_password'] != $_POST['repeated_password']){
+ print_red(_("The passwords you've entered as 'New password' and 'Repeated new password' do not match."));
+ } elseif ($_POST['new_password'] == ""){
+ print_red(_("The password you've entered as 'New password' is empty."));
+ }elseif($check_differ && (substr($_POST['current_password'], 0, $differ) == substr($_POST['new_password'], 0, $differ))){
+ print_red(_("The password used as new and current are too similar."));
+ }elseif($check_length && (strlen($_POST['new_password']) < $length)){
+ print_red(_("The password used as new is to short."));
+ }elseif($check_hook && $check_hook_output != ""){
+ print_red(_("External password changer reported a problem: ".$check_hook_output));
+ }else{
+
+ /* Try to connect via current password */
+ $tldap = new LDAP(
+ $ui->dn,
+ $_POST['current_password'],
+ $this->config->current['SERVER'],
+ isset($this->config->current['RECURSIVE']) && preg_match("/true/i",$this->config->current['RECURSIVE']),
+ isset($this->config->current['TLS']) && preg_match("/true/i",$this->config->current['TLS']));
+
+ /* connection Successfull ? */
+ if ($tldap->error != "Success"){
+ print_red(_("The password you've entered as your current password doesn't match the real one."));
+ }else{
+
+ /* Check GOsa permissions */
+ if (!preg_match("/w/i",$password_ACLS)){
+ print_red(_("You have no permissions to change your password."));
+ }else{
+ change_password ($ui->dn, $_POST['new_password']);
+ gosa_log ("User/password has been changed");
+ $ui->password= $_POST['new_password'];
+ $_SESSION['ui']= $ui;
+#$this->handle_post_events("modify",array("userPassword" => $_POST['new_password']));
+ return($smarty->fetch(get_template_path("changed.tpl", TRUE)));
+ }
+ }
+ }
+ }
+ return($smarty->fetch(get_template_path("password.tpl", TRUE)));
+ }
+
+ function remove_from_parent()
+ {
+ $this->handle_post_events("remove");
+ }
+
+ function save()
+ {
+ }
-
function plInfo()
{
return (array(
"plOptions" => array(),
"plProvidedAcls" => array())
- );
+ );
}
}
-
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
index 10b1cbd574506db78dc1cb7b037ff9ac16959d97..b8135bc6a271dbc69fe6da47a39080380cd4e763 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-$display = "";
-if (!$remove_lock){
-
- /* Assign headline image */
- $smarty->assign ('headimage',"");
- $display= "";
-
- $password_ACLS = $ui->get_permissions($ui->dn,"users/password");
- $smarty->assign("ChangeACL" , $password_ACLS);
- $smarty->assign("NotAllowed" , !preg_match("/w/i",$password_ACLS));
-
- /* Check for interaction */
- if ($_SERVER["REQUEST_METHOD"] == "POST"){
- if (isset($_POST['password_finish'])){
- $message= array();
-
- /* Is current password correct? */
- if ($_POST['current_password'] != ""){
- $tldap = new LDAP($ui->dn, $_POST['current_password'],
- $config->current['SERVER'],
- isset($config->current['RECURSIVE']) && $config->current['RECURSIVE'] == "true",
- isset($config->current['TLS']) && $config->current['TLS'] == "true");
- if ($tldap->error != "Success"){
- $message[]= _("The password you've entered as your current password doesn't match the real one.");
- }
- } else {
- $message[]= _("You need to specify your current password in order to proceed.");
- }
-
- /* Do new and repeated password fields match? */
- 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[]= _("The password you've entered as 'New password' is empty.");
- }
- }
-
- /* Password policy fulfilled? */
- if (isset($config->data['MAIN']['PWDIFFER'])){
- $l= $config->data['MAIN']['PWDIFFER'];
- if (substr($_POST['current_password'], 0, $l) == substr($_POST['new_password'], 0, $l)){
- $message[]= _("The password used as new and current are too similar.");
- }
- }
- if (isset($config->data['MAIN']['PWMINLEN'])){
- if (strlen($_POST['new_password']) < $config->data['MAIN']['PWMINLEN']){
- $message[]= _("The password used as new is to short.");
- }
- }
+/* Clear display */
+$display= "";
- if(!preg_match("/w/i",$password_ACLS)){
- $message[]= _("You have no permissions to change your password.");
- }
-
- if (count ($message) != 0){
-
- /* Show error message and continue editing */
- show_errors($message);
+if (!$remove_lock){
- } else {
+ /* Reset requested? */
+ if (isset($_POST['edit_cancel']) ||
+ (isset($_GET['reset']) && $_GET['reset'] == 1)){
- /* Passed quality check, just try to change the password now */
- $output= "";
- if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
- exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$ui->username." ".
- $_POST['current_password']." ".$_POST['new_password'], $resarr);
- if(count($resarr) > 0) {
- $output= join('\n', $resarr);
- }
- }
- if ($output != ""){
- $message[]= _("External password changer reported a problem: ".$output);
- show_errors($message);
- } else {
- change_password ($ui->dn, $_POST['new_password']);
- new log("modify","users/".get_class($this),$ui->dn,array(),"User has been changed");
- $ui->password= $_POST['new_password'];
- $_SESSION['ui']= $ui;
- $display= $smarty->fetch(get_template_path("changed.tpl", TRUE));
- }
- }
- }
+ del_lock ($ui->dn);
+ sess_del ('edit');
+ sess_del ('password');
}
- if ($display == ""){
- if((isset($config->data['MAIN']['ACCOUNT_EXPIRATION'])) &&
- !preg_match('/true/i', $config->data['MAIN']['ACCOUNT_EXPIRATION'])){
- $display= $smarty->fetch(get_template_path("password.tpl", TRUE));
- }else{
- $expired= ldap_expired_account($config, $ui->dn, $ui->username);
-
- if($expired == 4){
- $display= $smarty->fetch(get_template_path("nochange.tpl", TRUE));
- }else{
- $display= $smarty->fetch(get_template_path("password.tpl", TRUE));
- }
- }
+ /* Create password object on demand */
+ if (!isset($_SESSION['password']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ $_SESSION['password']= new password ($config, $ui->dn);
}
-}
+ $password= $_SESSION['password'];
+
+ /* Execute formular */
+ $display.= $password->execute ();
-$display = print_header(get_template_path('images/password.png'),_("Change password"), "").$display;
+ /* Page header*/
+ $display= print_header(get_template_path('images/password.png'),
+ _("Password settings"), "").$display;
+}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
index 280928cb73e8c07a8de991b9b5373bc1233ffd48..d7164f67e075154f978ba25fefed4470237bd7f5 100644 (file)
<div class="plugtop">
- <img class="center" alt="" src="{$headimage}" align="middle">{t}Password change not allowed{/t}
+ <img class="center" alt="" src="images/error.png" align="middle">{t}Password change not allowed{/t}>
</div>
<p>
index bc8251446010b8d70b09f9fbb2167b6a617df6a9..0787b70566491cc53cf958f85ade4faecbc66c3b 100644 (file)
-
<p>
{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>
<p>
-{if $NotAllowed}
- <b>{t}You have no permissions to change your password.{/t}</b>
-{else}
{t}Changing the password affects your authentification on mail, proxy, samba and unix services.{/t}
-{/if}
</p>
<table summary="" style="vertical-align:top; text-align:left;" cellpadding=4 border=0>
<tr>
<td><b><LABEL for="current_password">{t}Current password{/t}</LABEL></b></td>
- <td>
-{render acl=$ChangeACL}
- <input id="current_password" type="password" name="current_password" size="30" maxlength="40" onFocus="nextfield= 'new_password';">
-{/render}
- </td>
+ <td><input id="current_password" type="password" name="current_password" size="30" maxlength="40"
+ onFocus="nextfield= 'new_password';"></td>
</tr>
<tr>
<td><b><LABEL for="new_password">{t}New password{/t}</LABEL></b></td>
- <td>
-{render acl=$ChangeACL}
- <input id="new_password" type="password" name="new_password" size="30" maxlength="40" onFocus="nextfield= 'repeated_password';">
-{/render}
- </td>
+ <td><input id="new_password" type="password" name="new_password" size="30" maxlength="40"
+ onFocus="nextfield= 'repeated_password';"></td>
</tr>
<tr>
<td><b><LABEL for="repeated_password">{t}Repeat new password{/t}</LABEL></b></td>
- <td>
-{render acl=$ChangeACL}
- <input id="repeated_password" type="password" name="repeated_password" size="30" maxlength="40" onFocus="nextfield= 'password_finish';">
-{/render}
- </td>
+ <td><input id="repeated_password" type="password" name="repeated_password" size="30" maxlength="40"
+ onFocus="nextfield= 'password_finish';"></td>
</tr>
</table>
<br>
<p class="plugbottom">
-{render acl=$ChangeACL}
<input type=submit name="password_finish" value="{t}Set password{/t}">
-{/render}
-{render acl=$ChangeACL}
<input type=reset id="password_cancel" name="password_cancel" value="{t}Clear fields{/t}">
-{/render}
</p>
<input type="hidden" name="ignore">