Answer the question
In order to leave comments, you need to log in
How to check additional parameters during authentication in Symfony2?
In my case, I need to know the status (value in the database) of the user during authentication, and if the status is equal to a certain value, then do not authenticate and return an authorization error.
---
Found this option. So will it be right?
Answer the question
In order to leave comments, you need to log in
Если кому интересно сделал следующим образом:
Создал свой UserChecker и переопределил checker компонента security
class SecurityUserChecker extends UserChecker
{
/**
* Checks the user account before authentication.
*
* @param UserInterface $user a UserInterface instance
*/
public function checkPreAuth(UserInterface $user) {
parent::checkPreAuth($user);
if(!$user instanceof CustomUserInterface){
return;
}
if($user->isDeleted()){
$ex = new DeletedException('User account is deleted.');
$ex->setUser($user);
throw $ex;
}
}
}
security.user_checker:
class: UserBundle\Security\SecurityUserChecker
interface CustomUserInterface extends AdvancedUserInterface
{
/**
* @return boolean
*/
public function isDeleted();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question