From d203071de0798802c0024debd793ce89f180cc16 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Fri, 29 Nov 2019 15:43:53 +0100 Subject: First step to PHP 7.4 compatibility... --- src/Helpers/Authenticator.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Helpers/Authenticator.php b/src/Helpers/Authenticator.php index db33339b..28e48500 100644 --- a/src/Helpers/Authenticator.php +++ b/src/Helpers/Authenticator.php @@ -25,7 +25,7 @@ class Authenticator /** @var string[] */ protected $permissions; - /** @var int */ + /** @var int|string|null */ protected $passwordAlgorithm = PASSWORD_DEFAULT; /** @@ -163,13 +163,11 @@ class Authenticator */ public function verifyPassword(User $user, string $password) { - $algorithm = $this->passwordAlgorithm; - if (!password_verify($password, $user->password)) { return false; } - if (password_needs_rehash($user->password, $algorithm)) { + if (password_needs_rehash($user->password, $this->passwordAlgorithm)) { $this->setPassword($user, $password); } @@ -182,14 +180,12 @@ class Authenticator */ public function setPassword(User $user, string $password) { - $algorithm = $this->passwordAlgorithm; - - $user->password = password_hash($password, $algorithm); + $user->password = password_hash($password, $this->passwordAlgorithm); $user->save(); } /** - * @return int + * @return int|string|null */ public function getPasswordAlgorithm() { @@ -197,9 +193,9 @@ class Authenticator } /** - * @param int $passwordAlgorithm + * @param int|string|null $passwordAlgorithm */ - public function setPasswordAlgorithm(int $passwordAlgorithm) + public function setPasswordAlgorithm($passwordAlgorithm) { $this->passwordAlgorithm = $passwordAlgorithm; } -- cgit v1.2.3-54-g00ecf