Source
if (self::$data['mfaid'] == 0 && isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CWebUser {
public static $data = null;
/**
* Flag used to not to extend session lifetime in checkAuthentication.
*/
static $extend_session = true;
/**
* Disable automatic session extension.
*/
public static function disableSessionExtension() {
self::$extend_session = false;
}
/**
* Tries to login a user and populates self::$data on success.
*
* @param string $login user login
* @param string $password user password
*
* @throws Exception if user cannot be logged in
*
* @return bool
*/
public static function login(string $login, string $password): bool {
try {
self::$data = API::User()->login([
'username' => $login,
'password' => $password,
'userData' => true
]);
if (!self::$data) {
throw new Exception();
}
API::getWrapper()->auth = [
'type' => CJsonRpc::AUTH_TYPE_FRONTEND,
'auth' => self::$data['sessionid']
];
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
error(_('GUI access disabled.'));
throw new Exception();
}