mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Merge branch 'itflow-org:master' into balance-sheet
This commit is contained in:
@@ -17,7 +17,7 @@ if (isset($_POST['add_contact'])) {
|
||||
// Set a random password
|
||||
$password_hash = password_hash(randomString(), PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
if (!file_exists("uploads/clients/$client_id")) {
|
||||
mkdir("uploads/clients/$client_id");
|
||||
}
|
||||
@@ -68,6 +68,7 @@ if (isset($_POST['edit_contact'])) {
|
||||
require_once('post/contact_model.php');
|
||||
|
||||
$contact_id = intval($_POST['contact_id']);
|
||||
$send_email = intval($_POST['send_email']);
|
||||
|
||||
// Get Exisiting Contact Photo
|
||||
$sql = mysqli_query($mysqli,"SELECT contact_photo FROM contacts WHERE contact_id = $contact_id");
|
||||
@@ -93,7 +94,7 @@ if (isset($_POST['edit_contact'])) {
|
||||
}
|
||||
|
||||
// Send contact a welcome e-mail, if specified
|
||||
if (isset($_POST['send_email']) && !empty($auth_method) && !empty($config_smtp_host)) {
|
||||
if ($send_email && !empty($auth_method) && !empty($config_smtp_host)) {
|
||||
|
||||
// Un-sanitizied used in body of email
|
||||
$contact_name = $_POST['name'];
|
||||
@@ -102,14 +103,18 @@ if (isset($_POST['edit_contact'])) {
|
||||
$config_ticket_from_email_escaped = sanitizeInput($config_ticket_from_email);
|
||||
$config_ticket_from_name_escaped = sanitizeInput($config_ticket_from_name);
|
||||
|
||||
// Authentication info (azure, reset password, or tech-provided temporary password)
|
||||
|
||||
if ($auth_method == 'azure') {
|
||||
$password_info = "Login with your Microsoft (Azure AD) account.";
|
||||
} elseif (empty($_POST['contact_password'])) {
|
||||
$password_info = "Request a password reset at https://$config_base_url/portal/login_reset.php";
|
||||
} else {
|
||||
$password_info = $_POST['contact_password'];
|
||||
$password_info = $_POST['contact_password'] . " -- Please change on first login";
|
||||
}
|
||||
|
||||
$subject = sanitizeInput("Your new $session_company_name ITFlow account");
|
||||
$body = mysqli_real_escape_string($mysqli, "Hello, $contact_name<br><br>An ITFlow account has been set up for you. <br><br>Username: $email <br>Password: $password_info<br><br>Login URL: https://$config_base_url/portal/<br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email");
|
||||
$subject = sanitizeInput("Your new $session_company_name support portal account");
|
||||
$body = mysqli_real_escape_string($mysqli, "Hello, $contact_name<br><br>$session_company_name has created a support portal account for you. <br><br>Username: $email<br>Password: $password_info<br><br>Login URL: https://$config_base_url/portal/<br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email");
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$email', email_recipient_name = '$name', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject', email_content = '$body'");
|
||||
|
||||
@@ -280,3 +280,47 @@ if (isset($_POST['export_users_csv'])) {
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['ir_reset_user_password'])) {
|
||||
|
||||
// Incident response: allow mass reset of agent passwords
|
||||
|
||||
validateAdminRole();
|
||||
|
||||
validateCSRFToken($_POST['csrf_token']);
|
||||
|
||||
// Confirm logged-in user password, for security
|
||||
$admin_password = $_POST['admin_password'];
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM users WHERE user_id = $session_user_id");
|
||||
$userRow = mysqli_fetch_array($sql);
|
||||
if (!password_verify($admin_password, $userRow['user_password'])) {
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Incorrect password.";
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get agents/users, other than the current user
|
||||
$sql_users = mysqli_query($mysqli, "SELECT * FROM users WHERE (user_archived_at IS NULL AND user_id != $session_user_id)");
|
||||
|
||||
// Reset passwords
|
||||
while ($row = mysqli_fetch_array($sql_users)) {
|
||||
$user_id = intval($row['user_id']);
|
||||
$user_email = sanitizeInput($row['user_email']);
|
||||
$new_password = randomString();
|
||||
$user_specific_encryption_ciphertext = encryptUserSpecificKey(trim($new_password));
|
||||
|
||||
echo $user_email . " -- " . $new_password; // Show
|
||||
$new_password = password_hash($new_password, PASSWORD_DEFAULT);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE users SET user_password = '$new_password', user_specific_encryption_ciphertext = '$user_specific_encryption_ciphertext' WHERE user_id = $user_id");
|
||||
|
||||
echo "<br><br>";
|
||||
}
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'User', log_action = 'Modify', log_description = '$session_name reset ALL user passwords', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||
|
||||
exit; // Stay on the plain text password page
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user