From 06de3fde9a5660795428b58122eb2765e96693f7 Mon Sep 17 00:00:00 2001 From: DoctorPCComputers <48200537+doctorpccomputers@users.noreply.github.com> Date: Sat, 12 Dec 2020 21:15:50 +0300 Subject: [PATCH] Added password change (#2239) --- .../website_integration/AuthMeController.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/samples/website_integration/AuthMeController.php b/samples/website_integration/AuthMeController.php index e2eca93e3..538cdb882 100644 --- a/samples/website_integration/AuthMeController.php +++ b/samples/website_integration/AuthMeController.php @@ -70,6 +70,27 @@ abstract class AuthMeController { } return false; } + + + /** + * Changes password for player. + * + * @param string $username the username + * @param string $password the password + * @return bool true whether or not password change was successful + */ + function changePassword($username, $password) { + $mysqli = $this->getAuthmeMySqli(); + if ($mysqli !== null) { + $hash = $this->hash($password); + $stmt = $mysqli->prepare('UPDATE ' . self::AUTHME_TABLE . ' SET password=? ' + . 'WHERE username=?'); + $username_low = strtolower($username); + $stmt->bind_param('ss', $hash, $username_low); + return $stmt->execute(); + } + return false; + } /** * Hashes the given password.