Passwortprüfung eingebaut

This commit is contained in:
Matthias Grief
2024-12-02 13:25:32 +01:00
committed by Safak
parent ed6ce6d8b7
commit 331adbcd5b

View File

@@ -99,6 +99,16 @@ class User
return false;
}
/**
* Prüft, ob ein Passwort für diesen Benutzer korrekt ist
* @param string $password Zu prüfendes Passwort
* @return bool true, wenn korrekt, sonst false
*/
public function isPasswordCorrect(string $password): bool
{
return password_verify($password, $this->passwordHash);
}
/**
* Meldet den Benutzer an, wenn das Passwort richtig ist
* @param string $password Passwort
@@ -106,7 +116,7 @@ class User
*/
public function login(string $password): bool
{
if(!password_verify($password, $this->passwordHash)) {
if(!$this->isPasswordCorrect($password)) {
return false;
}