mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
- LSformElement_password : Ajout d'une fonctionnalité de vérification du mot
de passe dans l'annuaire. - LSldapObject : -> Ajout d'une méthode isNew() -> Correction/mise à jour des commentaires - LSform.js : Correction d'un bug dans la méthode onLSformElement_password_generate_btnClick
This commit is contained in:
parent
dd80110e6d
commit
b1dccb033e
6 changed files with 114 additions and 3 deletions
|
@ -89,6 +89,10 @@ class LSformElement_password extends LSformElement {
|
|||
$return['html'] .= $autogenerate_html;
|
||||
$id = "LSformElement_password_view_btn_".$this -> name."_".$numberId;
|
||||
$return['html'] .= "<img src='templates/images/view.png' id='$id' class='LSformElement_password_view_btn'/>\n";
|
||||
if (!$this -> attr_html -> attribute -> ldapObject-> isNew()) {
|
||||
$id = "LSformElement_password_verify_btn_".$this -> name."_".$numberId;
|
||||
$return['html'] .= "<img src='templates/images/verify.png' id='$id' class='LSformElement_password_verify_btn' alt=\"".('Vérifier le mot de passe')."\" title=\"".('Vérifier le mot de passe')."\" />\n";
|
||||
}
|
||||
|
||||
if (!empty($this -> values)) {
|
||||
$return['html'] .= "* "._('Modification uniquement').".";
|
||||
|
@ -109,6 +113,13 @@ class LSformElement_password extends LSformElement {
|
|||
function generatePassword() {
|
||||
return generatePassword($this -> params['html_options']['chars'],$this -> params['html_options']['lenght']);
|
||||
}
|
||||
|
||||
function verifyPassword($pwd) {
|
||||
if ($this -> attr_html -> attribute -> ldapObject -> isNew()) {
|
||||
return false;
|
||||
}
|
||||
return $GLOBALS['LSsession'] -> checkUserPwd($this -> attr_html -> attribute -> ldapObject,$pwd);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -574,7 +574,7 @@ class LSldapObject {
|
|||
* @param[in] $basedn string DN de base pour la recherche
|
||||
* @param[in] $params array Paramètres de recherche au format Net_LDAP2::search()
|
||||
*
|
||||
* @retval array Tableau d'objet correspondant au resultat de la recherche
|
||||
* @retval array Tableau d'objets correspondant au resultat de la recherche
|
||||
*/
|
||||
function listObjects($filter='',$basedn=NULL,$params=array()) {
|
||||
$retInfos=array();
|
||||
|
@ -769,6 +769,17 @@ class LSldapObject {
|
|||
return $retInfos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recherche un objet à partir de la valeur exact de son RDN
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $name string Valeur de son RDN
|
||||
* @param[in] $basedn string Le DN de base de la recherche
|
||||
*
|
||||
* @retval array Tableau d'objets correspondant au resultat de la recherche
|
||||
*/
|
||||
function searchObject($name,$basedn=NULL) {
|
||||
$filter = $this -> config['rdn'].'='.$name;
|
||||
return $this -> listObjects($filter,$basedn);
|
||||
|
@ -864,6 +875,8 @@ class LSldapObject {
|
|||
/**
|
||||
* Retourne le type de l'objet
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Le type de l'objet ($this -> type_name)
|
||||
*/
|
||||
function getType() {
|
||||
|
@ -873,6 +886,8 @@ class LSldapObject {
|
|||
/**
|
||||
* Retourne qui est l'utilisateur par rapport à cet object
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string 'admin'/'self'/'user' pour Admin , l'utilisateur lui même ou un simple utilisateur
|
||||
*/
|
||||
function whoami() {
|
||||
|
@ -884,6 +899,8 @@ class LSldapObject {
|
|||
/**
|
||||
* Retourne le label de l'objet
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Le label de l'objet ($this -> config['label'])
|
||||
*/
|
||||
function getLabel() {
|
||||
|
@ -894,11 +911,24 @@ class LSldapObject {
|
|||
/**
|
||||
* Supprime l'objet dans l'annuaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean True si l'objet à été supprimé, false sinon
|
||||
*/
|
||||
function remove() {
|
||||
return $GLOBALS['LSldap'] -> remove($this -> getDn());
|
||||
}
|
||||
|
||||
/**
|
||||
* L'objet est-il nouveau
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean True si l'objet est nouveau, false sinon
|
||||
*/
|
||||
function isNew() {
|
||||
return (!$this -> dn);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -32,7 +32,14 @@ var LSform = new Class({
|
|||
$$('img.LSformElement_password_view_btn').each(function(el) {
|
||||
el.addEvent('click',this.onLSformElement_password_view_btnClick.bind(this,el));
|
||||
}, this);
|
||||
|
||||
this.LSformElement_password_background_color = [];
|
||||
|
||||
this.initialiseLSformElement_password_generate();
|
||||
|
||||
$$('img.LSformElement_password_verify_btn').each(function(el) {
|
||||
el.addEvent('click',this.onLSformElement_password_verify_btnClick.bind(this,el));
|
||||
}, this);
|
||||
|
||||
this.initialiseLSformElement_select_object();
|
||||
},
|
||||
|
@ -49,6 +56,8 @@ var LSform = new Class({
|
|||
|
||||
initialiseLSformElement_password_generate: function() {
|
||||
$$('input.LSformElement_password_generate').each(function(el) {
|
||||
this.LSformElement_password_background_color[el.id] = el.getStyle('background-color');
|
||||
el.addEvent('click',this.onLSformElement_password_verify_inputClick.bind(this,el));
|
||||
el.addEvent('keyup',this.onLSformElement_password_generate_inputKeyUp.bind(this,el));
|
||||
}, this);
|
||||
},
|
||||
|
@ -219,7 +228,7 @@ var LSform = new Class({
|
|||
var getAttrNameAndIdValues = getAttrNameAndId.exec(img.id);
|
||||
var attrName = getAttrNameAndIdValues[1];
|
||||
var fieldId = 'LSformElement_password_' + attrName + '_' + getAttrNameAndIdValues[2];
|
||||
var viewBtnId = 'LSformElement_password_view_btn_userPassword_' + getAttrNameAndIdValues[2];
|
||||
var viewBtnId = 'LSformElement_password_view_btn_' + attrName + '_' + getAttrNameAndIdValues[2];
|
||||
|
||||
var data = {
|
||||
template: 'LSform',
|
||||
|
@ -301,6 +310,54 @@ var LSform = new Class({
|
|||
input.remove();
|
||||
this.initialiseLSformElement_password_generate();
|
||||
return newInput;
|
||||
},
|
||||
|
||||
onLSformElement_password_verify_btnClick: function(img) {
|
||||
var getAttrNameAndId = /LSformElement_password_verify_btn_(.*)_([0-9]*)/
|
||||
var getAttrNameAndIdValues = getAttrNameAndId.exec(img.id);
|
||||
var attrName = getAttrNameAndIdValues[1];
|
||||
var fieldId = 'LSformElement_password_' + attrName + '_' + getAttrNameAndIdValues[2];
|
||||
var verifyBtnId = 'LSformElement_password_verify_btn_' + attrName + '_' + getAttrNameAndIdValues[2];
|
||||
|
||||
var data = {
|
||||
template: 'LSform',
|
||||
action: 'verifyPassword',
|
||||
attribute: attrName,
|
||||
objecttype: $('LSform_objecttype').value,
|
||||
idform: $('LSform_idform').value,
|
||||
fieldId: fieldId,
|
||||
fieldValue: $(fieldId).value,
|
||||
objectdn: $('LSform_objectdn').value
|
||||
};
|
||||
LSdebug(data);
|
||||
data.imgload=varLSdefault.loadingImgDisplay(img);
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onLSformElement_password_verify_btnClickComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onLSformElement_password_verify_btnClickComplete: function(responseText, responseXML) {
|
||||
var data = Json.evaluate(responseText);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
if (data.verifyPassword) {
|
||||
// ok
|
||||
$(data.fieldId).setStyle('background-color','#73F386');
|
||||
}
|
||||
else {
|
||||
// nok
|
||||
$(data.fieldId).setStyle('background-color','#f59a67');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLSformElement_password_verify_inputClick: function(input) {
|
||||
input.setStyle('background-color',this.LSformElement_password_background_color[input.id]);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -101,6 +101,19 @@ if (!isset($_ERRORS)) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 'verifyPassword':
|
||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['fieldValue'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['objectdn'])) ) {
|
||||
$object = new $_REQUEST['objecttype']();
|
||||
$form = $object -> getForm($_REQUEST['idform']);
|
||||
$object -> loadData($_REQUEST['objectdn']);
|
||||
$field=$form -> getElement($_REQUEST['attribute']);
|
||||
$val = $field -> verifyPassword($_REQUEST['fieldValue']);
|
||||
$data = array(
|
||||
'verifyPassword' => $val,
|
||||
'fieldId' => $_REQUEST['fieldId']
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'LSrelation':
|
||||
|
|
|
@ -74,6 +74,6 @@ li.LSformElement_select_object_addBtn {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
img.LSformElement_select_object_deleteBtn, img.LSformElement_password_view_btn, img.LSformElement_password_generate_btn {
|
||||
img.LSformElement_select_object_deleteBtn, img.LSformElement_password_view_btn, img.LSformElement_password_generate_btn, img.LSformElement_password_verify_btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
BIN
trunk/templates/images/verify.png
Normal file
BIN
trunk/templates/images/verify.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 679 B |
Loading…
Reference in a new issue