<commit_before><?php
require_once "../database/database.php";

if (!isset($_POST["username"]) || !isset($_POST["password"])) {
	// Redirect to login page with error.
	header("Location: ../login.php");
	exit(1);
}

$link = get_mysqli_link();
$query = "SELECT password FROM users WHERE username=?";
$params = array($_POST["username"]);
$result = mysqli_prepared_query($link, $query, "s", $params);

if (password_verify($_POST["password"], $result["password"])) {
	// Successfully verified. Setup user session here.
} else {
	// Verification failed, redirect to login page.
}

?><commit_msg>Refactor login_handler.<commit_after><?php
require_once "../database/database.php";
require_once "../workers/user_worker.php";

if (!isset($_POST["username"]) || !isset($_POST["password"])) {
	// Redirect to login page with error.
	header("Location: ../login.php");
	exit(1);
}

$worker = new UserWorker();
$ret = $worker->checkLogin($_POST["username"], $_POST["password"]);

if ($ret == 0) {
	header("Location: ../index.php");
} else {
	header("Location: ../login.php?error=" . $ret);
}

?>
{'fraction_non_alphanumeric': 0.21686746987951808, 'fraction_numerical': 0.0027803521779425394, 'mean_word_length': 5.27906976744186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1431273', 'n_tokens_mistral': 352, 'n_tokens_neox': 346, 'n_words': 80}