Skip to content

Commit

Permalink
[Docs] Update recipe removing unexisting method
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu authored and greg0ire committed Oct 9, 2019
1 parent 90c9e07 commit 4aa0c76
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions docs/cookbook/recipe_sonata_admin_without_user_bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ more about it `here <https://symfony.com/doc/current/security/guard_authenticati
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
Expand Down Expand Up @@ -232,15 +231,7 @@ more about it `here <https://symfony.com/doc/current/security/guard_authenticati

public function checkCredentials($credentials, UserInterface $user): bool
{
if (!$this->passwordEncoder->isPasswordValid($user, $credentials['password'])) {
return false;
}

if (!$user->hasRole('ROLE_ADMIN')) {
throw new CustomUserMessageAuthenticationException("You don't have permission to access that page.");
}

return true;
return $this->passwordEncoder->isPasswordValid($user, $credentials['password']);
}

public function onAuthenticationFailure(Request $request, AuthenticationException $exception): RedirectResponse
Expand Down

0 comments on commit 4aa0c76

Please sign in to comment.