filter deactivated users who want to use the API; fix error-output in Customers::update()

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-22 11:42:13 +01:00
parent c1875132ef
commit a468fe50df
2 changed files with 12 additions and 6 deletions

View File

@@ -86,6 +86,12 @@ abstract class ApiCommand
}
$this->logger = FroxlorLogger::getInstanceOf($this->user_data);
// check whether the user is deactivated
if ($this->getUserDetail('deactivated') == 1) {
$this->logger()->logAction(LOG_ERROR, LOG_INFO, "[API] User '" . $this->getUserDetail('loginnname') . "' tried to use API but is deactivated");
throw new Exception("Account suspended", 406);
}
$this->initLang();
$this->initMail();

View File

@@ -199,7 +199,7 @@ class Customers extends ApiCommand implements ResourceEntity
standard_error(array(
'stringisempty',
'myname'
));
), '', true);
} elseif ($firstname == '' && $company == '') {
standard_error(array(
'stringisempty',
@@ -756,23 +756,23 @@ class Customers extends ApiCommand implements ResourceEntity
standard_error(array(
'stringisempty',
'myname'
));
), '', true);
} elseif ($firstname == '' && $company == '') {
standard_error(array(
'stringisempty',
'myfirstname'
));
), '', true);
} elseif ($email == '') {
standard_error(array(
'stringisempty',
'emailadd'
));
), '', true);
} elseif (! validateEmail($email)) {
standard_error('emailiswrong', $email);
standard_error('emailiswrong', $email, true);
} else {
if ($password != '') {
$password = validatePassword($password);
$password = validatePassword($password, true);
$password = makeCryptPassword($password);
} else {
$password = $result['password'];