mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Started Logs: Login attempts are now logged, created a logs list in the side nav
This commit is contained in:
20
login.php
20
login.php
@@ -7,6 +7,16 @@ if(!file_exists('config.php')){
|
||||
?>
|
||||
|
||||
<?php include("config.php"); ?>
|
||||
<?php include("functions.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
$ip = get_ip();
|
||||
$os = get_os();
|
||||
$browser = get_web_browser();
|
||||
$device = get_device();
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -25,9 +35,12 @@ if(isset($_POST['login'])){
|
||||
$token = $row['token'];
|
||||
$_SESSION['user_id'] = $row['user_id'];
|
||||
$_SESSION['name'] = $row['name'];
|
||||
|
||||
$name = $row['name'];
|
||||
$user_id = $row['user_id'];
|
||||
|
||||
if(empty($token)){
|
||||
$_SESSION['logged'] = TRUE;
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login Successful', log_description = '$name successfully logged in from $ip using $os | $browser on a $device', log_created_at = NOW(), user_id = $user_id");
|
||||
|
||||
header("Location: dashboard.php");
|
||||
}else{
|
||||
@@ -35,9 +48,12 @@ if(isset($_POST['login'])){
|
||||
|
||||
if(TokenAuth6238::verify($token,$current_code)){
|
||||
$_SESSION['logged'] = TRUE;
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login Successful', log_description = '$name successfully logged in with 2FA from $ip using $os | $browser on a $device', log_created_at = NOW(), user_id = $user_id");
|
||||
//header("Location: $config_start_page");
|
||||
header("Location: dashboard.php");
|
||||
}else{
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = '2FA Login Failed', log_description = '$name failed 2FA from $ip using $os | $browser on a $device', log_created_at = NOW(), user_id = $user_id");
|
||||
|
||||
$response = "
|
||||
<div class='alert alert-danger'>
|
||||
Invalid Code.
|
||||
@@ -48,6 +64,8 @@ if(isset($_POST['login'])){
|
||||
}
|
||||
|
||||
}else{
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login Failed', log_description = '$email failed to login from $ip using $os | $browser on a $device', log_created_at = NOW()");
|
||||
|
||||
$response = "
|
||||
<div class='alert alert-danger'>
|
||||
Incorrect email or password.
|
||||
|
||||
Reference in New Issue
Block a user