diff --git a/src/Interfaces/ValidateLoginModelInterface.php b/src/Interfaces/ValidateLoginModelInterface.php new file mode 100644 index 0000000..75dc41c --- /dev/null +++ b/src/Interfaces/ValidateLoginModelInterface.php @@ -0,0 +1,31 @@ +isModelExpired()) { + Log::debug("Login failed for {$username} - the login has now expired", "LOGIN"); + throw new LoginExpiredException(); + } + + if ($user->isModelDisabled()) { + Log::debug("Login failed for {$username} - the login has been disabled due to numerous failed login attempts", "LOGIN"); + throw new LoginDisabledFailedAttemptsException(); + } + } } if (!isset($activeUser)) { diff --git a/tests/unit/Fixtures/TestExpiredLoginProvider.php b/tests/unit/Fixtures/TestExpiredLoginProvider.php new file mode 100644 index 0000000..1f68e33 --- /dev/null +++ b/tests/unit/Fixtures/TestExpiredLoginProvider.php @@ -0,0 +1,13 @@ +assertTrue($testLoginProvider->isLoggedIn()); $this->assertEquals($user->UniqueIdentifier, $testLoginProvider->getModel()->UniqueIdentifier); } + + public function testExpiredLogin() + { + $user = new TestExpiredUser(); + $user->Username = "expiredlogin"; + $user->Password = "password"; + $user->save(); + + try { + $testLoginProvider = new TestExpiredLoginProvider(); + $testLoginProvider->login($user->Username, $user->Password); + + $this->fail("Expected User login to be expired"); + } catch (LoginExpiredException $exception) { + $this->assertEquals("Sorry, your login has now expired. Please contact the system administrator to address this issue.", $exception->getPublicMessage()); + } + } }