Commit 5f2d1d8b authored by Côme Chilliet's avatar Côme Chilliet

Merge branch '5996-recovery-system-needs-to-give-some-access-to-webservice' into '1.4-dev'

Resolve "Recovery system needs to give some access to webservice"

See merge request fusiondirectory/fd!600
parents 9be3c16d 91ea2831
......@@ -255,10 +255,15 @@ class passwordRecovery extends standAlonePage
}
/* Find the login of for the given email address */
function step2 ()
function step2 ($email = NULL)
{
global $config;
if ($email !== NULL) {
/* Special case when recovery is called from webservice */
$this->email_address = $email;
}
/* Search login corresponding to the mail */
$address_escaped = ldap_escape_f($this->email_address);
if ($this->usealternates) {
......@@ -279,10 +284,10 @@ class passwordRecovery extends standAlonePage
/* Only one ldap node should be found */
if ($ldap->count() < 1) {
$this->message[] = sprintf(_('There is no account using email "%s"'), htmlentities($this->email_address, ENT_COMPAT, 'UTF-8'));
return;
return FALSE;
} elseif ($ldap->count() > 1) {
$this->message[] = sprintf(_('There are several accounts using email "%s"'), htmlentities($this->email_address, ENT_COMPAT, 'UTF-8'));
return;
return FALSE;
}
$attrs = $ldap->fetch();
......@@ -290,7 +295,7 @@ class passwordRecovery extends standAlonePage
$method = passwordMethod::get_method($attrs['userPassword'][0], $attrs['dn']);
if (is_object($method) && $method->is_locked($attrs['dn'])) {
$this->message[] = sprintf(_('The user using email "%s" is locked. Please contact your administrator.'), htmlentities($this->email_address, ENT_COMPAT, 'UTF-8'));
return;
return FALSE;
}
$this->login = $attrs[$this->loginAttribute][0];
$this->step = 2;
......@@ -424,4 +429,19 @@ class passwordRecovery extends standAlonePage
$this->message[] = msgPool::invalid(_("There was a problem with mail server, confirmation email not sent"));
}
}
function getErrorMessages (): array
{
return $this->message;
}
function setLogin (string $login)
{
$this->login = $login;
}
function getLogin ()
{
return $this->login;
}
}
......@@ -34,23 +34,25 @@ class standAlonePage
$this->interactive = $interactive;
/* Destroy old session if exists.
Else you will get your old session back, if you not logged out correctly. */
session::destroy();
session::start();
$config = $this->loadConfig();
session::global_set('config', $config);
if ($this->interactive) {
/* Destroy old session if exists.
Else you will get your old session back, if you not logged out correctly. */
session::destroy();
session::start();
$config = $this->loadConfig();
session::global_set('config', $config);
/* Generate server list */
$this->directories = [];
foreach ($config->data['LOCATIONS'] as $key => $ignored) {
$this->directories[$key] = $key;
}
/* Generate server list */
$this->directories = [];
foreach ($config->data['LOCATIONS'] as $key => $ignored) {
$this->directories[$key] = $key;
$ui = new userinfoNoAuth(get_class($this));
session::global_set('ui', $ui);
}
$ui = new userinfoNoAuth(get_class($this));
session::global_set('ui', $ui);
static::init();
}
......@@ -84,6 +86,11 @@ class standAlonePage
{
global $config, $ssl, $ui;
if (!$this->interactive) {
$this->activated = $this->readLdapConfig();
return;
}
static::checkDirectoryChooser();
reset_errors();
......@@ -95,13 +102,11 @@ class standAlonePage
$ui = session::global_get('ui');
$config = session::global_get('config');
if ($this->interactive) {
timezone::setDefaultTimezoneFromConfig();
timezone::setDefaultTimezoneFromConfig();
Language::init();
Language::init();
$this->setupSmarty();
}
$this->setupSmarty();
$ssl = $this->checkForSSL();
......@@ -253,6 +258,11 @@ class standAlonePage
return preg_replace('/^&amp;/', '?', $params);
}
public function isActivated ()
{
return $this->activated;
}
static function run ()
{
session::start();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment