From 05709ff69f7ee06f0aa6f3b9ae497ba5d3fe3737 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 13 Jul 2020 14:39:04 +0200 Subject: [PATCH] removed deprecated stuff WIP --- src/Security/Passwords.php | 9 ++------ tests/Security/Passwords.static.phpt | 31 ---------------------------- 2 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 tests/Security/Passwords.static.phpt diff --git a/src/Security/Passwords.php b/src/Security/Passwords.php index cb695e85..b9917dba 100644 --- a/src/Security/Passwords.php +++ b/src/Security/Passwords.php @@ -46,10 +46,7 @@ public function hash(string $password): string throw new Nette\InvalidArgumentException('Password can not be empty.'); } - $hash = isset($this) - ? @password_hash($password, $this->algo, $this->options) // @ is escalated to exception - : @password_hash($password, PASSWORD_BCRYPT, func_get_args()[1] ?? []); // back compatibility with v2.x - + $hash = @password_hash($password, $this->algo, $this->options); // @ is escalated to exception if (!$hash) { throw new Nette\InvalidStateException('Computed hash is invalid. ' . error_get_last()['message']); } @@ -71,8 +68,6 @@ public function verify(string $password, string $hash): bool */ public function needsRehash(string $hash): bool { - return isset($this) - ? password_needs_rehash($hash, $this->algo, $this->options) - : password_needs_rehash($hash, PASSWORD_BCRYPT, func_get_args()[1] ?? []); // back compatibility with v2.x + return password_needs_rehash($hash, $this->algo, $this->options); } } diff --git a/tests/Security/Passwords.static.phpt b/tests/Security/Passwords.static.phpt deleted file mode 100644 index c50c9b57..00000000 --- a/tests/Security/Passwords.static.phpt +++ /dev/null @@ -1,31 +0,0 @@ - 5])) // @ is not static -); - - -Assert::true(@Passwords::verify('dg', '$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK')); // @ is not static -Assert::false(@Passwords::verify('dgx', '$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK')); // @ is not static - - -Assert::true(@Passwords::needsRehash('$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK')); // @ is not static