added graphical hint if password values are not equal

This commit is contained in:
Roland Gruber 2014-05-25 14:37:05 +00:00
parent 10cc9ae872
commit fba01c0ada
10 changed files with 71 additions and 3 deletions

View File

@ -448,6 +448,8 @@ class htmlInputField extends htmlElement {
protected $calendarFormat = '';
/** title attribute */
protected $title = null;
/** field ID that needs to have same value (e.g. password field) */
protected $sameValueFieldID = null;
/**
* Constructor
@ -570,6 +572,7 @@ class htmlInputField extends htmlElement {
echo '});';
echo "</script\n>";
}
// calendar
if ($this->showCalendar) {
echo '<script type="text/javascript">
jQuery(function() {
@ -578,6 +581,13 @@ class htmlInputField extends htmlElement {
</script>
';
}
// check value against reference field
if ($this->sameValueFieldID != null) {
echo '<script type="text/javascript">
checkFieldsHaveSameValues("' . $this->fieldName . '", "' . $this->sameValueFieldID . '");
</script>
';
}
if ($this->transient) {
return array();
}
@ -711,6 +721,16 @@ class htmlInputField extends htmlElement {
$this->title = htmlspecialchars($title);
}
/**
* Specifies the ID of a second field that must have the same value as this field.
* This field is marked red if different or green if equal.
*
* @param String $sameValueFieldID ID of reference field
*/
public function setSameValueFieldID($sameValueFieldID) {
$this->sameValueFieldID = $sameValueFieldID;
}
}
/**

View File

@ -1048,6 +1048,7 @@ class accountContainer {
$container->addElement(new htmlOutputText(_('Repeat password')));
$pwdInput2 = new htmlInputField('newPassword2');
$pwdInput2->setIsPassword(true);
$pwdInput2->setSameValueFieldID('newPassword1');
$container->addElement($pwdInput2, true);
// print force password change option
$forceChangeSupported = false;

View File

@ -2532,6 +2532,7 @@ class posixAccount extends baseModule implements passwordService {
$pwdTable->addElement($pwd1, true);
$pwd2 = new htmlTableExtendedInputField(_('Reenter password'), 'posixAccount_password2');
$pwd2->setIsPassword(true);
$pwd2->setSameValueFieldID('posixAccount_password');
$pwdTable->addElement($pwd2);
$return['password'] = new htmlTableRow(array(
$pwdTable

View File

@ -2267,6 +2267,7 @@ class sambaSamAccount extends baseModule implements passwordService {
$pwdTable->addElement($pwd1, true);
$pwd2 = new htmlTableExtendedInputField(_('Reenter password'), 'sambaSamAccount_password2');
$pwd2->setIsPassword(true);
$pwd2->setSameValueFieldID('sambaSamAccount_password');
$pwdTable->addElement($pwd2);
$return['password'] = new htmlTableRow(array(
$pwdTable

View File

@ -1713,6 +1713,7 @@ class windowsUser extends baseModule implements passwordService {
$pwdTable->addElement($pwd1, true);
$pwd2 = new htmlTableExtendedInputField(_('Reenter password'), 'windowsUser_unicodePwd2');
$pwd2->setIsPassword(true);
$pwd2->setSameValueFieldID('windowsUser_unicodePwd');
$pwdTable->addElement($pwd2);
$return['unicodePwd'] = new htmlTableRow(array(
$pwdTable

View File

@ -288,6 +288,13 @@ a.lamLogo {
margin-left: 5px;
}
input.markFail {
background-color: #ffc4ba;
}
input.markOk {
background-color: #abebaa;
}
.sortableList { list-style-type: none; margin: 0; padding: 0; }
.sortableList li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; }
.sortableList li span { position: absolute; margin-left: -1.3em; }

View File

@ -452,6 +452,7 @@ $password1 = new htmlTableExtendedInputField(_("New password"), 'passwd1', null,
$password1->setIsPassword(true);
$password2 = new htmlTableExtendedInputField(_("Reenter password"), 'passwd2');
$password2->setIsPassword(true);
$password2->setSameValueFieldID('passwd1');
$securitySettingsContent->addElement($password1, true);
$securitySettingsContent->addElement($password2, true);
$securitySettings = new htmlFieldset($securitySettingsContent, _("Security settings"), '../../graphics/security.png');

View File

@ -458,6 +458,7 @@ $pwd1->setIsPassword(true);
$passwordTable->addElement($pwd1, true);
$pwd2 = new htmlTableExtendedInputField(_("Reenter password"), 'masterpassword2', '');
$pwd2->setIsPassword(true);
$pwd2->setSameValueFieldID('masterpassword');
$passwordTable->addElement($pwd2, true);
$container->addElement($passwordTable, true);
$container->addElement(new htmlSpacer(null, '20px'), true);

View File

@ -3,7 +3,7 @@
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2013 Roland Gruber
Copyright (C) 2003 - 2014 Roland Gruber
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
@ -247,6 +247,7 @@ $container->addElement($profileNewPwd1, true);
$profileNewPwd2 = new htmlTableExtendedInputField(_("Reenter password"), 'addpassword2');
$profileNewPwd2->setIsPassword(true);
$profileNewPwd2->setFieldSize(15);
$profileNewPwd2->setSameValueFieldID('addpassword');
$container->addElement($profileNewPwd2, true);
$newProfileButton = new htmlButton('btnAddProfile', _('Add'));
$newProfileButton->setOnClick("jQuery('#action').val('add');showConfirmationDialog('" . _("Add profile") . "', '" .
@ -285,6 +286,7 @@ $container->addElement($profileSetPwd1, true);
$profileSetPwd2 = new htmlTableExtendedInputField(_("Reenter password"), 'setpassword2');
$profileSetPwd2->setIsPassword(true);
$profileSetPwd2->setFieldSize(15);
$profileSetPwd2->setSameValueFieldID('setpassword');
$container->addElement($profileSetPwd2, true);
$setPasswordProfileButton = new htmlButton('btnSetPasswordProfile', _('Set profile password'));
$setPasswordProfileButton->setOnClick("jQuery('#action').val('setpass');showConfirmationDialog('" . _("Set profile password") . "', '" .

View File

@ -3,7 +3,7 @@
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2013 Roland Gruber
Copyright (C) 2003 - 2014 Roland Gruber
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
@ -476,7 +476,7 @@ function bindShowNewZoneDialog(title, okText, cancelText) {
}
// creates the tooltips for help buttons
jQuery(document).ready(
function() {
jQuery(document).tooltip({
@ -493,3 +493,36 @@ jQuery(document).ready(
})
}
);
/**
* Checks if the given field has the same value as the reference field.
* Field is marked red if different and green if equal.
*
* @param fieldID ID of field to check
* @param fieldIDReference ID of reference field
*/
function checkFieldsHaveSameValues(fieldID, fieldIDReference) {
var field = jQuery('#' + fieldID);
var fieldRef = jQuery('#' + fieldIDReference);
var check =
function() {
var value = field.val();
var valueRef = fieldRef.val();
if ((value == '') && (valueRef == '')) {
field.removeClass('markFail');
field.removeClass('markOk');
}
else {
if (value == valueRef) {
field.removeClass('markFail');
field.addClass('markOk');
}
else {
field.addClass('markFail');
field.removeClass('markOk');
}
}
}
jQuery(field).keyup(check);
jQuery(fieldRef).keyup(check);
}