diff --git a/login.php b/login.php index d74b861b..ecd12b1b 100644 --- a/login.php +++ b/login.php @@ -15,15 +15,14 @@ if(isset($_POST['login'])){ if(mysqli_num_rows($sql) == 1){ $row = mysqli_fetch_array($sql); $token = $row['token']; + $_SESSION['user_id'] = $row['user_id']; + $_SESSION['name'] = $row['name']; + $_SESSION['client_id'] = $row['client_id']; + $client_id = $row['client_id']; if(empty($token)){ $_SESSION['logged'] = TRUE; - $_SESSION['user_id'] = $row['user_id']; - $_SESSION['name'] = $row['name']; - $_SESSION['client_id'] = $row['client_id']; - $client_id = $row['client_id']; - - + if($client_id > 0){ header("Location: client.php?client_id=$client_id"); }else{ @@ -35,10 +34,6 @@ if(isset($_POST['login'])){ if(TokenAuth6238::verify($token,$current_code)){ $_SESSION['logged'] = TRUE; - $_SESSION['user_id'] = $row['user_id']; - $_SESSION['name'] = $row['name']; - $_SESSION['client_id'] = $row['client_id']; - $client_id = $row['client_id']; header("Location: $config_start_page"); }else{ $response = " @@ -108,7 +103,7 @@ if(isset($_POST['login'])){
- +
diff --git a/post.php b/post.php index 71db8cbf..94834107 100644 --- a/post.php +++ b/post.php @@ -115,13 +115,23 @@ if(isset($_POST['edit_invoice_settings'])){ } -if(isset($_POST['settings_2fa'])){ +if(isset($_POST['enable_2fa'])){ $token = mysqli_real_escape_string($mysqli,$_POST['token']); mysqli_query($mysqli,"UPDATE users SET token = '$token' WHERE user_id = $session_user_id"); - $_SESSION['alert_message'] = "Updated User Token"; + $_SESSION['alert_message'] = "2FA Enabled and Token Updated"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if(isset($_POST['disable_2fa'])){ + + mysqli_query($mysqli,"UPDATE users SET token = '' WHERE user_id = $session_user_id"); + + $_SESSION['alert_message'] = "2FA Disabled you can now login without an additional code"; header("Location: " . $_SERVER["HTTP_REFERER"]); diff --git a/settings-user.php b/settings-user.php index e92241ce..2f0e278f 100644 --- a/settings-user.php +++ b/settings-user.php @@ -6,15 +6,10 @@
-
User Settings
+
Two Factor Authentication
- -
- value="1" id="customSwitch1"> - -
',TokenAuth6238::getBarCodeUrl('','',$secretkey,'PittPC-CRM')); + if(!empty($session_token)){ + //Generate QR Code based off the generated key + print sprintf('',TokenAuth6238::getBarCodeUrl('','',$session_token,'PittPC-CRM')); + } ?> +
- + + + + + +
-
- +
- +
@@ -48,10 +50,8 @@

- - - +