-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from chives/dev
Added UserCheckerInterface implementation to check if user is enabled before logging in
- Loading branch information
Showing
8 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* (c) FSi sp. z o.o. <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FSi\Bundle\AdminSecurityBundle\Security\UserChecker; | ||
|
||
use FSi\Bundle\AdminSecurityBundle\Security\User\UserInterface; | ||
use Symfony\Component\Security\Core\Exception\LockedException; | ||
use Symfony\Component\Security\Core\User\UserCheckerInterface; | ||
use Symfony\Component\Security\Core\User\UserInterface as SymfonyUserInterface; | ||
|
||
final class DisabledUserChecker implements UserCheckerInterface | ||
{ | ||
public function checkPreAuth(SymfonyUserInterface $user): void | ||
{ | ||
if (false === $user instanceof UserInterface) { | ||
return; | ||
} | ||
|
||
if (true === $user->isEnabled()) { | ||
return; | ||
} | ||
|
||
throw new LockedException("User {$user->getUsername()} is disabled"); | ||
} | ||
|
||
public function checkPostAuth(SymfonyUserInterface $user): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,16 @@ Feature: Secure admin panel | |
And I press "Login" button | ||
Then I should be redirected to "Admin panel" page | ||
|
||
Scenario: Login into admin panel using disabled user's credentials | ||
Given user "[email protected]" has been disabled | ||
And I am on the "Login" page | ||
When I fill form with valid admin login and password | ||
And I press "Login" button | ||
And I should see message: | ||
""" | ||
Invalid credentials. | ||
""" | ||
|
||
Scenario: Login into admin panel using bad credentials | ||
Given I am on the "Login" page | ||
When I fill form with invalid admin login and password | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters