diff --git a/src/server/cyberhex-code/install/create_admin.php b/src/server/cyberhex-code/install/create_admin.php index 2051c49..276ef9c 100644 --- a/src/server/cyberhex-code/install/create_admin.php +++ b/src/server/cyberhex-code/install/create_admin.php @@ -49,7 +49,7 @@ $success=0; die("Connection failed: " . $conn->connect_error); } - $stmt = $conn->prepare("INSERT INTO users (email, username, password,perms) VALUES (?, ?, ?, ?)"); + $stmt = $conn->prepare("INSERT INTO users (email, username, password,perms,allow_pw_login) VALUES (?, ?, ?, ?,1)"); $stmt->bind_param("ssss", $email, $username, $hash, $permissions); $email=htmlspecialchars($_POST["email"]); diff --git a/src/server/cyberhex-code/install/create_db.php b/src/server/cyberhex-code/install/create_db.php index 9bf1504..fb7873e 100644 --- a/src/server/cyberhex-code/install/create_db.php +++ b/src/server/cyberhex-code/install/create_db.php @@ -68,6 +68,7 @@ telegram_id VARCHAR(255), user_hex_id VARCHAR(255), credential_id VARBINARY(64), + allow_pw_login INT, public_key TEXT, counter INT )"; diff --git a/src/server/cyberhex-code/system/insecure_zone/php/login.php b/src/server/cyberhex-code/system/insecure_zone/php/login.php index 7941e18..db9a38b 100644 --- a/src/server/cyberhex-code/system/insecure_zone/php/login.php +++ b/src/server/cyberhex-code/system/insecure_zone/php/login.php @@ -271,19 +271,27 @@ async function checkRegistration() { // Check if the user exists and verify the password if ($result->num_rows > 0) { $row = $result->fetch_assoc(); - if (password_verify($password, $row['password'])) { - $_SESSION["username"]=$username; - $_SESSION["login"]=true; - $_SESSION["perms"]=$row["perms"]; - $_SESSION["email"]=$row["email"]; - $_SESSION["telegram_id"]=$row["telegram_id"]; - - echo ''; - exit(); - } else { + if($row["allow_pw_login"]==1){ + if (password_verify($password, $row['password'])) { + $_SESSION["username"]=$username; + $_SESSION["login"]=true; + $_SESSION["perms"]=$row["perms"]; + $_SESSION["email"]=$row["email"]; + $_SESSION["telegram_id"]=$row["telegram_id"]; + $_SESSION["allow_pw_login"]=$row["allow_pw_login"]; + + echo ''; + exit(); + } else { + echo ''; + } + } + else{ echo ''; + Password login is disabled on your account. Please use your passkey + '; } } else { echo ' +
+ + "); + }else{ + echo(""); + } + ?> + + +