Unverified Commit 193bf798 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(passwordRecovery) Use new error objects in password recovery

issue #6071
Showing with 23 additions and 13 deletions
+23 -13
...@@ -170,8 +170,13 @@ class passwordRecovery extends standAlonePage ...@@ -170,8 +170,13 @@ class passwordRecovery extends standAlonePage
$ldap->cd($config->current['BASE']); $ldap->cd($config->current['BASE']);
$ldap->create_missing_trees($token); $ldap->create_missing_trees($token);
if (!$ldap->success()) { if (!$ldap->success()) {
return msgPool::ldaperror($ldap->get_error(), return new SimplePluginLdapError(
$token, LDAP_MOD, get_class()); NULL,
$token,
NULL,
$ldap->get_error(),
$ldap->get_errno()
);
} }
fusiondirectory_log("Created token branch ".$token); fusiondirectory_log("Created token branch ".$token);
} }
...@@ -194,12 +199,17 @@ class passwordRecovery extends standAlonePage ...@@ -194,12 +199,17 @@ class passwordRecovery extends standAlonePage
} }
if (!$ldap->success()) { if (!$ldap->success()) {
return msgPool::ldaperror($ldap->get_error(), return new SimplePluginLdapError(
$dn, LDAP_ADD, get_class()); NULL,
$dn,
($add ? LDAP_ADD : LDAP_MOD),
$ldap->get_error(),
$ldap->get_errno()
);
} }
/* Everything went well */ /* Everything went well */
return ''; return NULL;
} }
function checkToken ($token) function checkToken ($token)
...@@ -242,10 +252,10 @@ class passwordRecovery extends standAlonePage ...@@ -242,10 +252,10 @@ class passwordRecovery extends standAlonePage
$ldap->search($filter, ['dn']); $ldap->search($filter, ['dn']);
if ($ldap->count() < 1) { if ($ldap->count() < 1) {
$this->message[] = sprintf(_('Did not find an account with login "%s"'), htmlentities($this->login, ENT_COMPAT, 'UTF-8')); $this->message[] = new FusionDirectoryError(htmlescape(sprintf(_('Did not find an account with login "%s"'), $this->login)));
return; return;
} elseif ($ldap->count() > 1) { } elseif ($ldap->count() > 1) {
$this->message[] = sprintf(_('Found multiple accounts with login "%s"'), htmlentities($this->login, ENT_COMPAT, 'UTF-8')); $this->message[] = new FusionDirectoryError(htmlescape(sprintf(_('Found multiple accounts with login "%s"'), $this->login)));
return; return;
} }
...@@ -283,10 +293,10 @@ class passwordRecovery extends standAlonePage ...@@ -283,10 +293,10 @@ class passwordRecovery extends standAlonePage
/* Only one ldap node should be found */ /* Only one ldap node should be found */
if ($ldap->count() < 1) { if ($ldap->count() < 1) {
$this->message[] = sprintf(_('There is no account using email "%s"'), htmlentities($this->email_address, ENT_COMPAT, 'UTF-8')); $this->message[] = new FusionDirectoryError(htmlescape(sprintf(_('There is no account using email "%s"'), $this->email_address)));
return FALSE; return FALSE;
} elseif ($ldap->count() > 1) { } elseif ($ldap->count() > 1) {
$this->message[] = sprintf(_('There are several accounts using email "%s"'), htmlentities($this->email_address, ENT_COMPAT, 'UTF-8')); $this->message[] = new FusionDirectoryError(htmlescape(sprintf(_('There are several accounts using email "%s"'), $this->email_address)));
return FALSE; return FALSE;
} }
...@@ -294,7 +304,7 @@ class passwordRecovery extends standAlonePage ...@@ -294,7 +304,7 @@ class passwordRecovery extends standAlonePage
$method = passwordMethod::get_method($attrs['userPassword'][0], $attrs['dn']); $method = passwordMethod::get_method($attrs['userPassword'][0], $attrs['dn']);
if (is_object($method) && $method->is_locked($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')); $this->message[] = new FusionDirectoryError(htmlescape(sprintf(_('The user using email "%s" is locked. Please contact your administrator.'), $this->email_address)));
return FALSE; return FALSE;
} }
$this->login = $attrs[$this->loginAttribute][0]; $this->login = $attrs[$this->loginAttribute][0];
...@@ -349,7 +359,7 @@ class passwordRecovery extends standAlonePage ...@@ -349,7 +359,7 @@ class passwordRecovery extends standAlonePage
if (mail_utf8($this->email_address, FALSE, $this->from_mail, $this->mail_subject, $body)) { if (mail_utf8($this->email_address, FALSE, $this->from_mail, $this->mail_subject, $body)) {
$this->step = 3; $this->step = 3;
} else { } else {
$this->message[] = _('Contact your administrator, there was a problem with mail server'); $this->message[] = new FusionDirectoryError(htmlescape(_('Contact your administrator, there was a problem with mail server')));
} }
$smarty = get_smarty(); $smarty = get_smarty();
...@@ -362,7 +372,7 @@ class passwordRecovery extends standAlonePage ...@@ -362,7 +372,7 @@ class passwordRecovery extends standAlonePage
$uniq_id_from_mail = validate($_GET['uniq']); $uniq_id_from_mail = validate($_GET['uniq']);
if (!$this->checkToken($uniq_id_from_mail)) { if (!$this->checkToken($uniq_id_from_mail)) {
$this->message[] = _("This token is invalid"); $this->message[] = new FusionDirectoryError(htmlescape(_('This token is invalid')));
return; return;
} }
...@@ -426,7 +436,7 @@ class passwordRecovery extends standAlonePage ...@@ -426,7 +436,7 @@ class passwordRecovery extends standAlonePage
$this->step = 5; $this->step = 5;
$smarty->assign('changed', TRUE); $smarty->assign('changed', TRUE);
} else { } else {
$this->message[] = _('There was a problem with mail server, confirmation email not sent'); $this->message[] = new FusionDirectoryError(htmlescape(_('There was a problem with mail server, confirmation email not sent')));
} }
} }
......
Supports Markdown
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