summaryrefslogtreecommitdiff
path: root/src/Helpers/Authenticator.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2019-11-30 15:37:48 +0100
committerGitHub <noreply@github.com>2019-11-30 15:37:48 +0100
commita18c7d13fcae0af77cdaef1947f2160cbf1dc56a (patch)
tree98633eb27bc514e51643766c0c4c45fc5cecfdd3 /src/Helpers/Authenticator.php
parent14f8d208b817d8d7dccebdb5f7a6ada2bcb9d5f4 (diff)
parente80fb54522c307afec3d8bb474a47dd9d2d5da64 (diff)
Merge pull request #682 from MyIgel/php7.4
PHP 7.4 compatibility, PHP min version 7.2, Twig 3
Diffstat (limited to 'src/Helpers/Authenticator.php')
-rw-r--r--src/Helpers/Authenticator.php16
1 files 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;
}