JezK
Edit File: 2fa.php
<?php session_start(); include("app/main.php"); if (!isset($_SESSION['temp_bdcUserID'])) { echo "<script>location.replace('index.php');</script>"; exit; } if (isset($_POST['verify'])) { $code = $_POST['code']; $userId = $_SESSION['temp_bdcUserID']; if ($bdc->verify2FACode($userId, $code)) { // Success! Finalize login $_SESSION['bdcUserID'] = $_SESSION['temp_bdcUserID']; $_SESSION['bdcCode'] = $_SESSION['temp_bdcCode']; $_SESSION['bdcName'] = $_SESSION['temp_bdcName']; $_SESSION['bdcUserPassword'] = $_SESSION['temp_bdcUserPassword']; $_SESSION['USER_IP'] = $_SESSION['temp_USER_IP']; $_SESSION['USER_AGENT'] = $_SESSION['temp_USER_AGENT']; $session_token = bin2hex(random_bytes(32)); $_SESSION['session_token'] = $session_token; $bdc->updateSession($session_token, $_SESSION['bdcUserID']); $bdc->clear2FACode($_SESSION['bdcUserID']); // Clean up temp sessions unset($_SESSION['temp_bdcUserID']); unset($_SESSION['temp_bdcCode']); unset($_SESSION['temp_bdcName']); unset($_SESSION['temp_bdcUserPassword']); unset($_SESSION['temp_USER_IP']); unset($_SESSION['temp_USER_AGENT']); echo "<script>location.replace('dashboard.php');</script>"; exit; } else { echo "<script>alert('Invalid or expired 2FA code. Please try again.');</script>"; } } ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>2FA Verification - NABFINS</title> <link rel="icon" href="/wp-content/uploads/2020/11/logo-68x80.png" sizes="32x32" /> <link href="css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="css/style.css"> <style> .login-container { margin-top: 100px; max-width: 400px; padding: 30px; background: #fff; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); } .cs-login { width: 100%; margin-top: 20px; } .logo-img { max-width: 150px; margin-bottom: 30px; } </style> </head> <body style="background-color: #f4f7f6;"> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4 login-container text-center"> <img src="images/logo.png" alt="Logo" class="logo-img"> <h4 style="margin-bottom: 20px; color: #6a0000;">2FA Verification</h4> <p>Please enter the 6-digit code sent to your email.</p> <form method="post"> <div class="form-group"> <input type="text" name="code" class="form-control text-center" placeholder="Enter 6-digit code" maxlength="6" pattern="\d{6}" required autofocus style="font-size: 24px; letter-spacing: 5px;"> </div> <button type="submit" name="verify" class="btn btn-primary cs-login">Verify & Login</button> <div style="margin-top: 20px;"> <a href="index.php" style="color: #6a0000;">Back to Login</a> </div> </form> </div> </div> </div> </body> </html>