forked from Adleraci/adlerka.top
Fix register
This commit is contained in:
parent
5c2d906fb0
commit
856c3c8fdc
@ -143,21 +143,29 @@ function doRegister($firstname, $lastname, $email, $password, $activation_token)
|
|||||||
{
|
{
|
||||||
global $mysqli, $routerConfig;
|
global $mysqli, $routerConfig;
|
||||||
$status = ["Status" => "Fail"];
|
$status = ["Status" => "Fail"];
|
||||||
|
|
||||||
if (!empty($activation_token) && !empty($email) && !empty($password) && !empty($firstname) && !empty($lastname) && isEmailAvailable($email)) {
|
if (!empty($activation_token) && !empty($email) && !empty($password) && !empty($firstname) && !empty($lastname) && isEmailAvailable($email)) {
|
||||||
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
|
$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"];
|
$privilege_level = $routerConfig["logged_in_default_permission_level"];
|
||||||
|
|
||||||
/** @noinspection SpellCheckingInspection */
|
/** @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();
|
$stmt->execute();
|
||||||
|
|
||||||
if ($stmt->affected_rows > 0) {
|
if ($stmt->affected_rows > 0) {
|
||||||
$status["Status"] = "Success";
|
$status["Status"] = "Success";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function changePassword($oldPassword, $newPassword): array
|
function changePassword($oldPassword, $newPassword): array
|
||||||
{
|
{
|
||||||
global $mysqli;
|
global $mysqli;
|
||||||
|
Loading…
Reference in New Issue
Block a user