/** * Attempt to locate the account based on the passed in email address and reset that password * * StdClass Object is returned * $result->success = true/false * $result->message = The message to show the user * * @return object $result The result of the password reset attempt */ public function passwordReset() { $account = false; if (isset($_POST['login']['username'])) { $username = $_POST['login']['username']; $account = $this->getOne("where username = '******'"); } $result = new StdClass(); if ($account) { $newPwd = Cart66Common::randomString(); $account->password = md5($newPwd); $account->save(); $email = $account->email; $subject = Cart66Setting::getValue('reset_subject'); $message = Cart66Setting::getValue('reset_intro'); $message .= "\n\nYour new password is: {$newPwd}"; $headers = 'From: ' . Cart66Setting::getValue('reset_from_name') . ' <' . Cart66Setting::getValue('reset_from_address') . '>' . "\r\n\\"; Cart66Notifications::mail($email, $subject, $message, $headers); $result->success = true; $result->message = "A new password has been emailed to {$email}"; } else { $result->success = false; $result->message = "We couldn't find an account with that username."; } return $result; }