From 749f2472614642720682a29cac09cc84fdab738c Mon Sep 17 00:00:00 2001 From: grandeljay Date: Wed, 30 Aug 2023 13:19:45 +0200 Subject: [PATCH] refactor: rename `generatePassword` to `passwordToHash` --- src/classes/wishthis/User.php | 2 +- src/pages/login.php | 2 +- src/pages/profile.php | 2 +- src/pages/register.php | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/classes/wishthis/User.php b/src/classes/wishthis/User.php index 21a617e4..5c50737c 100644 --- a/src/classes/wishthis/User.php +++ b/src/classes/wishthis/User.php @@ -36,7 +36,7 @@ class User throw new \Exception('Unable to find user with ID ' . $user_id . '. Does it exist?'); } - public static function generatePassword(string $plainPassword): string + public static function passwordToHash(string $plainPassword): string { return sha1($plainPassword); } diff --git a/src/pages/login.php b/src/pages/login.php index f98b4751..e279b462 100644 --- a/src/pages/login.php +++ b/src/pages/login.php @@ -15,7 +15,7 @@ $page = new Page(__FILE__, __('Login')); */ if (isset($_POST['login'], $_POST['email'], $_POST['password'])) { $email = Sanitiser::getEmail($_POST['email']); - $password = User::generatePassword($_POST['password']); + $password = User::passwordToHash($_POST['password']); $database ->query( diff --git a/src/pages/profile.php b/src/pages/profile.php index 6619385a..4a9b12bc 100644 --- a/src/pages/profile.php +++ b/src/pages/profile.php @@ -79,7 +79,7 @@ if (isset($_POST['user-id'], $_POST['section'])) { && !empty($_POST['user-password-repeat']) && $_POST['user-password'] === $_POST['user-password-repeat'] ) { - $set[] = '`password` = "' . User::generatePassword($_POST['user-password']) . '"'; + $set[] = '`password` = "' . User::passwordToHash($_POST['user-password']) . '"'; $loginRequired = true; } diff --git a/src/pages/register.php b/src/pages/register.php index 3ae6826e..baf17e36 100644 --- a/src/pages/register.php +++ b/src/pages/register.php @@ -92,7 +92,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) { `password_reset_valid_until` = NULL WHERE `id` = :user_id;', array( - 'user_password' => User::generatePassword($_POST['password']), + 'user_password' => User::passwordToHash($_POST['password']), 'user_id' => $user->id, ) ); @@ -133,7 +133,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) { );', array( 'user_email' => $user_email, - 'user_password' => User::generatePassword($_POST['password']), + 'user_password' => User::passwordToHash($_POST['password']), 'user_language' => $locale_user, ) ); @@ -157,7 +157,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) { );', array( 'user_email' => $user_email, - 'user_password' => User::generatePassword($_POST['password']), + 'user_password' => User::passwordToHash($_POST['password']), 'user_language' => $locale_user, ) );