LSsession : fix handling subDn in recoverPassword feature

This commit is contained in:
Benjamin Renard 2020-08-06 17:01:51 +02:00
parent ba85e5c2fc
commit d5d88d2601
3 changed files with 20 additions and 20 deletions

View file

@ -708,10 +708,10 @@ class LSsession {
// topDn
if (isset($_POST['LSsession_topDn']) && $_POST['LSsession_topDn'] != '' ){
self :: $topDn = $_POST['LSsession_topDn'];
self :: setSubDn($_POST['LSsession_topDn']);
}
else {
self :: $topDn = self :: $ldapServer['ldap_config']['basedn'];
self :: setSubDn(self :: $ldapServer['ldap_config']['basedn']);
}
$_SESSION['LSsession_topDn']=self :: $topDn;
@ -831,6 +831,8 @@ class LSsession {
}
elseif (!empty($username)) {
$users = LSauth :: username2LSobjects($username);
if (!is_array($users))
return;
}
else {
self :: log_debug('recoverPasswd(): no username or recoveryHash provided.');
@ -2786,7 +2788,7 @@ class LSsession {
}
/**
* Ajax method when change ldapserver on login form
* Ajax method when change ldapserver on login/recoveryPassword form
*
* @param[in] $data array The return data address
*
@ -2814,20 +2816,6 @@ class LSsession {
}
}
/**
* Ajax method when change ldapserver on recoverPassword form
*
* @param[in] $data array The return data address
*
* @retval void
**/
public static function ajax_onLdapServerChangedRecoverPassword(&$data) {
if ( isset($_REQUEST['server']) ) {
self :: setLdapServer($_REQUEST['server']);
$data=array('recoverPassword' => isset(self :: $ldapServer['recoverPassword']));
}
}
/**
* Set globals from the ldap server
*

View file

@ -29,7 +29,7 @@ var LSsession_recoverPassword = new Class({
server: server,
imgload: imgload
};
new Request({url: 'ajax/class/LSsession/onLdapServerChangedRecoverPassword', data: data, onSuccess: this.onLdapServerChangedComplete.bind(this)}).send();
new Request({url: 'ajax/class/LSsession/onLdapServerChangedLogin', data: data, onSuccess: this.onLdapServerChangedComplete.bind(this)}).send();
},
onLdapServerChangedComplete: function(responseText, responseXML){
@ -37,14 +37,24 @@ var LSsession_recoverPassword = new Class({
var data = JSON.decode(responseText);
LSdebug(data);
if ( varLSdefault.checkAjaxReturn(data) ) {
if (data.list_topDn) {
$('LSsession_topDn').getParent().set('html',data.list_topDn);
$('LSsession_topDn_label').set('html',data.subDnLabel);
$$('.recoverpasswordform-level').each(function(el) {
el.setStyle('display','block');
});
}
else {
this.recoverpasswordformLevelHide();
}
if (data.recoverPassword) {
this.enableInput();
}
}
},
loginformLevelHide: function(){
$$('.loginform-level').each(function(el) {
recoverpasswordformLevelHide: function(){
$$('.recoverpasswordform-level').each(function(el) {
el.setStyle('display','none');
});
$('LSsession_topDn').empty();

View file

@ -14,6 +14,8 @@
<dd {if count($ldapservers) <= 1}style="display: none"{/if}>
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options options=$ldapservers selected=$ldapServerId}</select>
</dd>
<dt class='recoverpasswordform-level' id='LSsession_topDn_label' {if count($ldapservers) <= 1}style="display: none"{/if}>{tr msg="Level"}</dt>
<dd class='recoverpasswordform-level' {if count($ldapservers) <= 1}style="display: none"{/if}><select name='LSsession_topDn' id='LSsession_topDn'></select></dd>
<dt>{tr msg="Identifier"}</dt>
<dd><input type='text' name='LSsession_user' /></dd>
<dd><input type='submit' value='{tr msg="Validate"|escape:"quotes"}' /></dd>