mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
LSformElement_password : Added a view hashed password button.
This commit is contained in:
parent
193172bf26
commit
c9ec2062e2
4 changed files with 54 additions and 0 deletions
|
@ -463,6 +463,7 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
|
||||||
'html_type' => 'password',
|
'html_type' => 'password',
|
||||||
'html_options' => array(
|
'html_options' => array(
|
||||||
'generationTool' => true,
|
'generationTool' => true,
|
||||||
|
'viewHash' => true,
|
||||||
'autoGenerate' => false,
|
'autoGenerate' => false,
|
||||||
'lenght' => 8,
|
'lenght' => 8,
|
||||||
'chars' => array (
|
'chars' => array (
|
||||||
|
|
BIN
public_html/images/default/view_hash.png
Normal file
BIN
public_html/images/default/view_hash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 779 B |
|
@ -124,6 +124,7 @@ class LSformElement_password extends LSformElement {
|
||||||
'generate' => _('Generate a password.'),
|
'generate' => _('Generate a password.'),
|
||||||
'verify' => _('Compare with stored password.'),
|
'verify' => _('Compare with stored password.'),
|
||||||
'view' => _('Display password.'),
|
'view' => _('Display password.'),
|
||||||
|
'viewHash' => _('Display hashed password.'),
|
||||||
'hide' => _('Hide password.'),
|
'hide' => _('Hide password.'),
|
||||||
'mail' => _("The password will be sent by mail if changed. Click to disable automatic notification."),
|
'mail' => _("The password will be sent by mail if changed. Click to disable automatic notification."),
|
||||||
'nomail' => _("The password will not be sent if changed. Click to enable automatic notification."),
|
'nomail' => _("The password will not be sent if changed. Click to enable automatic notification."),
|
||||||
|
@ -137,6 +138,7 @@ class LSformElement_password extends LSformElement {
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'generate' => ($this -> params['html_options']['generationTool']==True),
|
'generate' => ($this -> params['html_options']['generationTool']==True),
|
||||||
|
'viewHash' => ($this -> params['html_options']['viewHash']==True),
|
||||||
'verify' => (!$this -> attr_html -> attribute -> ldapObject-> isNew())
|
'verify' => (!$this -> attr_html -> attribute -> ldapObject-> isNew())
|
||||||
);
|
);
|
||||||
if (isset($this -> params['html_options']['mail'])) {
|
if (isset($this -> params['html_options']['mail'])) {
|
||||||
|
@ -233,6 +235,24 @@ class LSformElement_password extends LSformElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function ajax_viewHash(&$data) {
|
||||||
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) ) {
|
||||||
|
if (LSsession ::loadLSobject($_REQUEST['objecttype'])) {
|
||||||
|
$object = new $_REQUEST['objecttype']();
|
||||||
|
$object -> loadData($_REQUEST['objectdn']);
|
||||||
|
if (LSsession::canAccess($_REQUEST['objecttype'],$_REQUEST['objectdn'],null,$_REQUEST['attribute'])) {
|
||||||
|
$values = $object -> getValue($_REQUEST['attribute']);
|
||||||
|
if (is_string($values[0])) {
|
||||||
|
$data = array (
|
||||||
|
'hash' => $values[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -7,6 +7,16 @@ var LSformElement_password_field = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialiseLSformElement_password_field: function() {
|
initialiseLSformElement_password_field: function() {
|
||||||
|
// ViewHashBtn
|
||||||
|
if (this.params['viewHash'] && varLSform.objectdn!= "") {
|
||||||
|
this.viewHashBtn = new Element('img');
|
||||||
|
this.viewHashBtn.src = varLSdefault.imagePath('view_hash.png');
|
||||||
|
this.viewHashBtn.addClass('btn');
|
||||||
|
this.viewHashBtn.addEvent('click',this.onViewHashBtnClick.bind(this));
|
||||||
|
this.viewHashBtn.injectAfter(this.input);
|
||||||
|
varLSdefault.addHelpInfo(this.viewHashBtn,'LSformElement_password','viewHash');
|
||||||
|
}
|
||||||
|
|
||||||
// Mail
|
// Mail
|
||||||
if (this.params['mail']) {
|
if (this.params['mail']) {
|
||||||
if ((this.params.mail['canEdit']==1)||(!$type(this.params.mail['canEdit']))) {
|
if ((this.params.mail['canEdit']==1)||(!$type(this.params.mail['canEdit']))) {
|
||||||
|
@ -209,5 +219,28 @@ var LSformElement_password_field = new Class({
|
||||||
}
|
}
|
||||||
(function(){this.verifyFx.start(this.bgColor);}).delay(1000, this);
|
(function(){this.verifyFx.start(this.bgColor);}).delay(1000, this);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onViewHashBtnClick: function() {
|
||||||
|
var data = {
|
||||||
|
template: 'LSformElement_password',
|
||||||
|
action: 'viewHash',
|
||||||
|
attribute: this.name,
|
||||||
|
objecttype: varLSform.objecttype,
|
||||||
|
objectdn: varLSform.objectdn
|
||||||
|
};
|
||||||
|
data.imgload=varLSdefault.loadingImgDisplay(this.viewHashBtn);
|
||||||
|
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onViewHashBtnClickComplete.bind(this)}).send();
|
||||||
|
},
|
||||||
|
|
||||||
|
onViewHashBtnClickComplete: function(responseText, responseXML) {
|
||||||
|
var data = JSON.decode(responseText);
|
||||||
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||||
|
if (data.hash) {
|
||||||
|
// ok
|
||||||
|
this.input.value=data.hash;
|
||||||
|
this.changeInputType('view');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue