Fix register

This commit is contained in:
Bruno Rybársky 2024-02-03 18:09:48 +01:00
parent 5c2d906fb0
commit 856c3c8fdc

@ -143,21 +143,29 @@ function doRegister($firstname, $lastname, $email, $password, $activation_token)
{
global $mysqli, $routerConfig;
$status = ["Status" => "Fail"];
if (!empty($activation_token) && !empty($email) && !empty($password) && !empty($firstname) && !empty($lastname) && isEmailAvailable($email)) {
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$stmt = $mysqli->prepare("INSERT INTO Users (FirstName, LastName, Email, PasswordHash, PrivilegeLevel, isActivated, ActivationToken, RegisteredAt) VALUES (?, ?, ?, ?, ?, 1, ?, NOW())");
$stmt = $mysqli->prepare("UPDATE Users SET FirstName=?, LastName=?, Email=?, PasswordHash=?, PrivilegeLevel=?, isActivated=1, ActivationToken=?, RegisteredAt=NOW() WHERE ActivationToken = ?");
$privilege_level = $routerConfig["logged_in_default_permission_level"];
/** @noinspection SpellCheckingInspection */
$stmt->bind_param("ssssis", $firstname, $lastname, $email, $passwordHash, $privilege_level, $activation_token);
$stmt->bind_param("ssssiss", $firstname, $lastname, $email, $passwordHash, $privilege_level, $activation_token, $activation_token);
$stmt->execute();
if ($stmt->affected_rows > 0) {
$status["Status"] = "Success";
}
$stmt->close();
}
return $status;
}
function changePassword($oldPassword, $newPassword): array
{
global $mysqli;