Unverified Commit 550d95fa authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(login) Use new Error classes in login methods

issue #6071
Showing with 37 additions and 6 deletions
+37 -6
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2019-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*! \class FusionDirectoryWarning
*/
class FusionDirectoryWarning extends FusionDirectoryError
{
public function computeMsgDialogParameters (): array
{
return [_('Warning'), $this->htmlMessage, WARNING_DIALOG, static::formatTrace($this)];
}
}
......@@ -36,7 +36,7 @@ class LoginMethod
}
/*! \brief Runs schemaCheck if activated in configuration */
static function runSchemaCheck ()
static function runSchemaCheck (): bool
{
global $config;
if ($config->get_cfg_value('schemaCheck') != 'TRUE') {
......@@ -51,9 +51,10 @@ class LoginMethod
foreach ($str as $tr) {
if (!$tr['STATUS']) {
if ($tr['IS_MUST_HAVE']) {
return htmlescape(_('LDAP schema check reported errors:')).'<br/><br/><i>'.htmlescape($tr['MSG']).'</i>';
throw new FusionDirectoryError(htmlescape(_('LDAP schema check reported errors:')).'<br/><br/><i>'.htmlescape($tr['MSG']).'</i>');
} else {
msg_dialog::display(_('LDAP schema error'), htmlescape($tr['MSG']), WARNING_DIALOG);
$warning = new FusionDirectoryWarning(nl2br(htmlescape(sprintf(_("LDAP schema error:\n%s"), $tr['MSG']))));
$warning->display();
}
}
}
......@@ -81,7 +82,7 @@ class LoginMethod
/*! \brief Check username for invalid characters and check password is not empty
* Also trims username */
static function validateUserInput ()
static function validateUserInput (): bool
{
global $message, $smarty;
static::$username = trim(static::$username);
......@@ -97,7 +98,7 @@ class LoginMethod
}
/*! \brief Performs an LDAP bind with $username and $password */
static function ldapLoginUser ()
static function ldapLoginUser (): bool
{
global $ui, $config, $message, $smarty;
/* Login as user, initialize user ACL's */
......@@ -116,7 +117,7 @@ class LoginMethod
}
/*! \brief Called after successful login, return FALSE if account is expired */
static function loginAndCheckExpired ()
static function loginAndCheckExpired (): bool
{
global $ui, $config, $plist, $message, $smarty;
......
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