implemented update pw function
This commit is contained in:
parent
5965e1df81
commit
dd6e98fe28
@ -123,7 +123,7 @@ class AuthModel extends Database
|
|||||||
$randomPw = bin2hex(random_bytes(12 / 2));
|
$randomPw = bin2hex(random_bytes(12 / 2));
|
||||||
$hashedPassword = password_hash($randomPw, PASSWORD_DEFAULT);
|
$hashedPassword = password_hash($randomPw, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
$this->forgottenPwUpdate($email, $hashedPassword);
|
||||||
|
|
||||||
$betreff = "Passwort zurücksetzen bei bibArts";
|
$betreff = "Passwort zurücksetzen bei bibArts";
|
||||||
$nachricht = "Hallo,\n\nhier ihr temporäres Passwort:\n\n $randomPw \n\n Bitte beachten Sie, dass das Passwort nur 2 stunden Gülltig ist. \nViele Grüße,\nbibArts Team";
|
$nachricht = "Hallo,\n\nhier ihr temporäres Passwort:\n\n $randomPw \n\n Bitte beachten Sie, dass das Passwort nur 2 stunden Gülltig ist. \nViele Grüße,\nbibArts Team";
|
||||||
@ -177,6 +177,35 @@ class AuthModel extends Database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updatePassword($email, $oldpw, $newpw){
|
||||||
|
if(!$this->login($email, $oldpw)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$requiredFields = [$email, $oldpw, $newpw];
|
||||||
|
foreach ($requiredFields as $field) {
|
||||||
|
if (empty($field)) {
|
||||||
|
return "Bitte füllen Sie alle Felder aus";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$hashedPassword = password_hash($newpw, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO user (email, password)
|
||||||
|
VALUES (:email, :password)";
|
||||||
|
|
||||||
|
try{
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
return $stmt->execute([
|
||||||
|
':email' => $email,
|
||||||
|
':password' => $hashedPassword,
|
||||||
|
]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function checkDoublePw($password1, $password2){
|
public function checkDoublePw($password1, $password2){
|
||||||
if($password1 === $password2){
|
if($password1 === $password2){
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user