mirror of
https://github.com/itflow-org/itflow
synced 2026-12-04 01:59:00 +00:00
API / service accounts take no seat on the agent user limit, the managed instance's or config.php's: getActiveAgentUserCount() leaves them out, so the seats taken, the limit checks and the report to the manager do too; one can be added, enabled, restored or bulk enabled when every seat is taken, New User stays open with the window saying so, and turning an active one back into an agent who signs in needs a free seat (serviceAccountLeavingNeedsSeat()); 26.12.5 changelog
This commit is contained in:
@@ -52,9 +52,11 @@ if (isset($_POST['add_user'])) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
// An invite waiting for them holds a seat already - it is this one
|
||||
// An invite waiting for them holds a seat already - it is this one. An API / service account
|
||||
// takes none (functions/service_account.php)
|
||||
$open = userInviteFor($email);
|
||||
if (agentUserLimitReached($open && userInviteState($open) === 'pending' ? intval($open['invite_id']) : 0)) {
|
||||
$service_new = !empty($_POST['service_account']) && serviceAccountsReady();
|
||||
if (!$service_new && agentUserLimitReached($open && userInviteState($open) === 'pending' ? intval($open['invite_id']) : 0)) {
|
||||
flashAlert(agentUserLimitMessage(), 'error');
|
||||
redirect();
|
||||
}
|
||||
@@ -268,6 +270,11 @@ if (isset($_POST['edit_user'])) {
|
||||
if (intval($row['role_is_admin']) && !intval($role['role_is_admin'])) {
|
||||
userGuardLastAdmin($row, 'a role without admin');
|
||||
}
|
||||
// An API / service account takes no seat - an agent who signs in does (functions/service_account.php)
|
||||
if (serviceAccountLeavingNeedsSeat($row, $_POST)) {
|
||||
flashAlert('<strong>' . escapeHtml($row['user_name']) . '</strong> is still an API / service account, which takes no seat - as an agent who signs in it would need one. ' . agentUserLimitMessage(), 'error');
|
||||
redirect();
|
||||
}
|
||||
|
||||
mysqli_query($mysqli, "UPDATE users SET user_name = '" . escapeSql($name) . "', user_email = '" . escapeSql($email) . "', user_role_id = " . intval($role['role_id']) . " WHERE user_id = $user_id");
|
||||
$force_mfa = !empty($_POST['force_mfa']) ? 1 : 0;
|
||||
@@ -332,8 +339,9 @@ if (isset($_GET['activate_user'])) {
|
||||
$row = userForRequest($_GET['activate_user']);
|
||||
$user_id = intval($row['user_id']);
|
||||
|
||||
// Only a user who isn't already using a seat can push the count over the limit
|
||||
if ((intval($row['user_status']) !== 1 || $row['user_archived_at']) && agentUserLimitReached()) {
|
||||
// Only a user who isn't already using a seat can push the count over the limit - and an API /
|
||||
// service account takes none (functions/service_account.php)
|
||||
if ((intval($row['user_status']) !== 1 || $row['user_archived_at']) && !serviceAccountIs($user_id) && agentUserLimitReached()) {
|
||||
flashAlert(agentUserLimitMessage(), 'error');
|
||||
redirect();
|
||||
}
|
||||
@@ -443,7 +451,8 @@ if (isset($_POST['restore_user'])) {
|
||||
$row = userForRequest($_POST['user_id'] ?? 0);
|
||||
$user_id = intval($row['user_id']);
|
||||
|
||||
if (agentUserLimitReached()) {
|
||||
// An API / service account takes no seat (functions/service_account.php)
|
||||
if (!serviceAccountIs($user_id) && agentUserLimitReached()) {
|
||||
flashAlert(agentUserLimitMessage(), 'error');
|
||||
redirect();
|
||||
}
|
||||
@@ -549,7 +558,7 @@ if (isset($_POST['bulk_disable_users']) || isset($_POST['bulk_activate_users']))
|
||||
if ($row['user_archived_at'] || intval($row['user_status']) === ($activate ? 1 : 0)) {
|
||||
continue;
|
||||
}
|
||||
if ($activate && agentUserLimitReached()) {
|
||||
if ($activate && !serviceAccountIs($user_id) && agentUserLimitReached()) {
|
||||
$kept[] = $row['user_name'];
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user