Symfony implement - Custom Form Password Authenticator http://symfony.com/doc/current/cookbook/security/custom_password_authenticator.html
So this part of code get my user provider class defined in services.yml via UserProviderInterface
and return UserInterface
.
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
{
try {
$user = $userProvider->loadUserByUsername($token->getUsername());
By default my custom user class provider implement AdvancedUserInterface
with some more functions: http://api.symfony.com/2.6/Symfony/Component/Security/Core/User/AdvancedUserInterface.html
class Users implements AdvancedUserInterface, \Serializable
Question: How to implement AdvancedUserInterface
with UserProviderInterface
. Or I simply need to recreate this AdvancedUserInterface
functions manually and check manually after loaded user object?
Thanks. I hope you understand.
EDITED: It look like AdvancedUser Interface functions not called in custom password authentication automaticaly. So after get user object need to call manual this functions
try {
$user = $userProvider->loadUserByUsername($token->getUsername());
if ($user->isAccountNonExpired()){ throw new AuthenticationException('expired');}
if ($user->isAccountNonLocked()){ throw new AuthenticationException('locked');}
if ($user->isCredentialsNonExpired()){ throw new AuthenticationException('credExpired');}
if (!$user->isEnabled()){ throw new AuthenticationException('disabled');}