From 47cbb529f5723b246125ae083a193e11481b89ef Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sun, 12 Mar 2023 07:01:30 +0200 Subject: initializing classroom structure using anom framework --- classes/authenticator/PasswordTrait.php | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 classes/authenticator/PasswordTrait.php (limited to 'classes/authenticator/PasswordTrait.php') diff --git a/classes/authenticator/PasswordTrait.php b/classes/authenticator/PasswordTrait.php new file mode 100644 index 0000000..22976d8 --- /dev/null +++ b/classes/authenticator/PasswordTrait.php @@ -0,0 +1,40 @@ + $this->cost] + ); + } + + public function isPasswordValid(UserInterface $user, string $plainPassword): bool + { + return password_verify( + $plainPassword, + $user->getPassword() + ); + } + + public function setCost(int $cost): void + { + if ($cost < 4 || $cost > 12) { + throw new \InvalidArgumentException('Cost must be in the range of 4-31.'); + } + $this->cost = $cost; + } +} -- cgit v1.2.3