Fix plain text in user authendication -- part 2.
This commit is contained in:
parent
c06e1bd64b
commit
a4f839bfc5
@ -37,8 +37,17 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$login_message = "Database error (prepare failed).";
|
||||
$result = false;
|
||||
} else {
|
||||
$stmt->bind_param("ss", $new_username, $new_password);
|
||||
// Hash the password before storing it.
|
||||
// Never store login passwords in plaintext.
|
||||
$password_hash = password_hash($new_password, PASSWORD_DEFAULT);
|
||||
if ($password_hash === false) {
|
||||
$login_message = "Password hashing failed.";
|
||||
$result = false;
|
||||
} else {
|
||||
// Store the hash (not the plaintext password).
|
||||
$stmt->bind_param("ss", $new_username, $password_hash);
|
||||
$result = $stmt->execute();
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user