SessionOperator::setNotification(SessionOperator::CHANGED_PASSWORD); // Send a password changed confirmation email to the user $mail = new Email($email, $userDetails["firstName"], $userDetails["lastName"]); $mail->preparePasswordConfirmEmail(); $mail->sentEmail(); HelperOperator::redirectTo("../index.php"); } else { SessionOperator::setFormInput($passwordFields); } HelperOperator::redirectTo("../views/change_password_view.php?email=" . $email); } else { if (isset($_POST["changePasswordSignedIn"])) { // Retrieve Passwords $passwordFields = ["currentPassword" => $_POST["currentPassword"], "password1" => $_POST["password1"], "password2" => $_POST["password2"]]; // Get current user session $user = SessionOperator::getUser(); // Current password is correct and both new passwords are valid and match if (!ValidationOperator::hasEmtpyFields($passwordFields) && ValidationOperator::isCurrentPassword($passwordFields["currentPassword"]) && ValidationOperator::validPasswords($passwordFields["password1"], $passwordFields["password2"])) { QueryOperator::updatePassword($user->getEmail(), $passwordFields["password2"]); SessionOperator::setNotification(SessionOperator::CHANGED_PASSWORD); // Send a password changed confirmation email to the user $mail = new Email($user->getEmail(), $user->getFirstName(), $user->getLastName()); $mail->preparePasswordConfirmEmail(); $mail->sentEmail(); } else { SessionOperator::setFormInput($passwordFields); } HelperOperator::redirectTo("../views/account_view.php"); } } }