mirror of https://github.com/itflow-org/itflow
More logAction function updates to client portal login amd cleaned up the client login portal for better presentation of vars
This commit is contained in:
parent
577d97b471
commit
412462a4c0
|
|
@ -139,7 +139,8 @@ if ($item_type == "Document") {
|
|||
|
||||
// Logging
|
||||
$name = mysqli_real_escape_string($mysqli, $doc_title);
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Sharing', log_action = 'View', log_description = 'Viewed shared $item_type $doc_title_escaped via link', log_client_id = $client_id, log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
logAction("Share", "View", "Viewed shared $item_type $doc_title_escaped via link", $client_id);
|
||||
|
||||
|
||||
} elseif ($item_type == "File") {
|
||||
$file_sql = mysqli_query($mysqli, "SELECT * FROM files WHERE file_id = $item_related_id AND file_client_id = $client_id LIMIT 1");
|
||||
|
|
@ -254,7 +255,7 @@ if ($item_type == "Document") {
|
|||
|
||||
// Logging
|
||||
$name = sanitizeInput($login_row['login_name']);
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Sharing', log_action = 'View', log_description = 'Viewed shared $item_type $name via link', log_client_id = $client_id, log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
logAction("Share", "View", "Viewed shared $item_type $name via link", $client_id);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
218
portal/login.php
218
portal/login.php
|
|
@ -31,8 +31,8 @@ if($config_client_portal_enable == 0) {
|
|||
exit();
|
||||
}
|
||||
|
||||
$ip = sanitizeInput(getIP());
|
||||
$user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);
|
||||
$session_ip = sanitizeInput(getIP());
|
||||
$session_user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);
|
||||
|
||||
$sql_settings = mysqli_query($mysqli, "SELECT config_azure_client_id, config_login_message FROM settings WHERE company_id = 1");
|
||||
$settings = mysqli_fetch_array($sql_settings);
|
||||
|
|
@ -50,34 +50,54 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) {
|
|||
$password = $_POST['password'];
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
|
||||
header("HTTP/1.1 401 Unauthorized");
|
||||
|
||||
$_SESSION['login_message'] = 'Invalid e-mail';
|
||||
|
||||
} else {
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM users LEFT JOIN contacts ON user_id = contact_user_id WHERE user_email = '$email' AND user_archived_at IS NULL AND user_type = 2 AND user_status = 1 LIMIT 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
if ($row['user_auth_method'] == 'local') {
|
||||
$client_id = intval($row['contact_client_id']);
|
||||
$user_id = intval($row['user_id']);
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$user_email = sanitizeInput($row['user_email']);
|
||||
$user_auth_method = sanitizeInput($row['user_auth_method']);
|
||||
|
||||
if ($user_auth_method == 'local') {
|
||||
if (password_verify($password, $row['user_password'])) {
|
||||
|
||||
$_SESSION['client_logged_in'] = true;
|
||||
$_SESSION['client_id'] = intval($row['contact_client_id']);
|
||||
$_SESSION['user_id'] = intval($row['user_id']);
|
||||
$_SESSION['contact_id'] = intval($row['contact_id']);
|
||||
$_SESSION['client_id'] = $client_id;
|
||||
$_SESSION['user_id'] = $user_id;
|
||||
$_SESSION['contact_id'] = $contact_id;
|
||||
$_SESSION['login_method'] = "local";
|
||||
|
||||
header("Location: index.php");
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Client Login', log_action = 'Success', log_description = 'Client contact $row[contact_email] successfully logged in locally', log_ip = '$ip', log_user_agent = '$user_agent', log_client_id = $row[contact_client_id], log_user_id = $row[user_id]");
|
||||
// Logging
|
||||
logAction("Client Login", "Success", "Client contact $user_email successfully logged in locally", $client_id, $user_id);
|
||||
|
||||
} else {
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Client Login', log_action = 'Failed', log_description = 'Failed client portal login attempt using $email (incorrect password for contact ID $row[contact_id])', log_ip = '$ip', log_user_agent = '$user_agent', log_client_id = $row[contact_client_id], log_user_id = $row[user_id]");
|
||||
|
||||
// Logging
|
||||
logAction("Client Login", "Failed", "Failed client portal login attempt using $email (incorrect password for contact ID $contact_id)", $client_id, $user_id);
|
||||
|
||||
header("HTTP/1.1 401 Unauthorized");
|
||||
$_SESSION['login_message'] = 'Incorrect username or password.';
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Client Login', log_action = 'Failed', log_description = 'Failed client portal login attempt using $email (invalid email/not allowed local auth)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
|
||||
// Logging
|
||||
logAction("Client Login", "Failed", "Failed client portal login attempt using $email (invalid email/not allowed local auth)");
|
||||
|
||||
header("HTTP/1.1 401 Unauthorized");
|
||||
|
||||
$_SESSION['login_message'] = 'Incorrect username or password.';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,120 +105,120 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) {
|
|||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title><?php echo $company_name; ?> | Client Portal Login</title>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title><?php echo $company_name; ?> | Client Portal Login</title>
|
||||
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex">
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex">
|
||||
|
||||
<!-- Favicon - If Fav Icon exists else use the default one -->
|
||||
<?php if(file_exists('../uploads/favicon.ico')) { ?>
|
||||
<link rel="icon" type="image/x-icon" href="../uploads/favicon.ico">
|
||||
<?php } ?>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
|
||||
|
||||
<!-- Theme style -->
|
||||
<link rel="stylesheet" href="../dist/css/adminlte.min.css">
|
||||
|
||||
<!-- Google Font: Source Sans Pro -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body class="hold-transition login-page">
|
||||
<div class="login-box">
|
||||
<div class="login-logo">
|
||||
<?php if (!empty($company_logo)) { ?>
|
||||
<img alt="<?=$company_name?> logo" height="110" width="380" class="img-fluid" src="<?php echo "../uploads/settings/$company_logo"; ?>">
|
||||
<?php } else { ?>
|
||||
<b><?=$company_name?></b> <br>Client Portal Login</h2>
|
||||
<!-- Favicon - If Fav Icon exists else use the default one -->
|
||||
<?php if(file_exists('../uploads/favicon.ico')) { ?>
|
||||
<link rel="icon" type="image/x-icon" href="../uploads/favicon.ico">
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body login-card-body">
|
||||
<?php if(!empty($config_login_message)){ ?>
|
||||
<p class="login-box-msg px-0"><?php echo nl2br($config_login_message); ?></p>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
|
||||
|
||||
<!-- Theme style -->
|
||||
<link rel="stylesheet" href="../dist/css/adminlte.min.css">
|
||||
|
||||
<!-- Google Font: Source Sans Pro -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body class="hold-transition login-page">
|
||||
<div class="login-box">
|
||||
<div class="login-logo">
|
||||
<?php if (!empty($company_logo)) { ?>
|
||||
<img alt="<?=$company_name?> logo" height="110" width="380" class="img-fluid" src="<?php echo "../uploads/settings/$company_logo"; ?>">
|
||||
<?php } else { ?>
|
||||
<b><?=$company_name?></b> <br>Client Portal Login</h2>
|
||||
<?php } ?>
|
||||
<?php
|
||||
if (!empty($_SESSION['login_message'])) { ?>
|
||||
<p class="login-box-msg text-danger">
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body login-card-body">
|
||||
<?php if(!empty($config_login_message)){ ?>
|
||||
<p class="login-box-msg px-0"><?php echo nl2br($config_login_message); ?></p>
|
||||
<?php } ?>
|
||||
<?php
|
||||
echo $_SESSION['login_message'];
|
||||
unset($_SESSION['login_message']);
|
||||
if (!empty($_SESSION['login_message'])) { ?>
|
||||
<p class="login-box-msg text-danger">
|
||||
<?php
|
||||
echo $_SESSION['login_message'];
|
||||
unset($_SESSION['login_message']);
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<form method="post">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" placeholder="Registered Client Email" name="email" required autofocus>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-envelope"></span>
|
||||
<form method="post">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" placeholder="Registered Client Email" name="email" required autofocus>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-envelope"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<input type="password" class="form-control" placeholder="Client Password" name="password" required>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-lock"></span>
|
||||
<div class="input-group mb-3">
|
||||
<input type="password" class="form-control" placeholder="Client Password" name="password" required>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-lock"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success btn-block mb-3" name="login">Sign in</button>
|
||||
<button type="submit" class="btn btn-success btn-block mb-3" name="login">Sign in</button>
|
||||
|
||||
<hr>
|
||||
<hr>
|
||||
|
||||
<?php
|
||||
if (!empty($config_smtp_host)) { ?>
|
||||
<h5 class="text-center"><a href="login_reset.php">Forgot password?</a></h5>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (!empty($config_smtp_host)) { ?>
|
||||
<h5 class="text-center"><a href="login_reset.php">Forgot password?</a></h5>
|
||||
if (!empty($azure_client_id)) { ?>
|
||||
<hr>
|
||||
<div class="col text-center">
|
||||
<a href="login_microsoft.php">
|
||||
<button type="button" class="btn btn-secondary">Login with Microsoft Entra</button>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (!empty($azure_client_id)) { ?>
|
||||
<hr>
|
||||
<div class="col text-center">
|
||||
<a href="login_microsoft.php">
|
||||
<button type="button" class="btn btn-secondary">Login with Microsoft Entra</button>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<!-- /.login-card-body -->
|
||||
|
||||
</div>
|
||||
<!-- /.login-card-body -->
|
||||
<!-- /.div.card -->
|
||||
|
||||
</div>
|
||||
<!-- /.div.card -->
|
||||
<!-- /.login-box -->
|
||||
|
||||
</div>
|
||||
<!-- /.login-box -->
|
||||
<?php
|
||||
if (!$config_whitelabel_enabled) {
|
||||
echo '<small class="text-muted">Powered by ITFlow</small>';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (!$config_whitelabel_enabled) {
|
||||
echo '<small class="text-muted">Powered by ITFlow</small>';
|
||||
}
|
||||
?>
|
||||
<!-- jQuery -->
|
||||
<script src="../plugins/jquery/jquery.min.js"></script>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="../plugins/jquery/jquery.min.js"></script>
|
||||
<!-- Bootstrap 4 -->
|
||||
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 4 -->
|
||||
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<script src="../dist/js/adminlte.min.js"></script>
|
||||
|
||||
<!-- AdminLTE App -->
|
||||
<script src="../dist/js/adminlte.min.js"></script>
|
||||
<!-- Prevents resubmit on refresh or back -->
|
||||
<script src="../js/login_prevent_resubmit.js"></script>
|
||||
|
||||
<!-- Prevents resubmit on refresh or back -->
|
||||
<script src="../js/login_prevent_resubmit.js"></script>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue