diff --git a/include/class_passwordRecovery.inc b/include/class_passwordRecovery.inc index 527a4a44168fafb91842743bf497a31035097f8c..eed3f85bae5d14475377b17014b143e000f55b86 100644 --- a/include/class_passwordRecovery.inc +++ b/include/class_passwordRecovery.inc @@ -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; + } } diff --git a/include/class_standAlonePage.inc b/include/class_standAlonePage.inc index 42fcdea249efd6f624e80d84c02521c9129196d4..30517ab37727aee10e06b4c1356600ed37bc1674 100644 --- a/include/class_standAlonePage.inc +++ b/include/class_standAlonePage.inc @@ -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,10 @@ class standAlonePage { global $config, $ssl, $ui; + if (!$this->interactive) { + return; + } + static::checkDirectoryChooser(); reset_errors(); @@ -95,13 +101,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();