ユーザー(成功)がhttp_basic_ldap
でログインした後にコードを実行するにはどうすればよいですか?symfony 3.3 http_basic_ldapログイン(成功)のイベントですか?
http://symfony.com/doc/3.3/security/ldap.html#configuration-example-for-http-basic
(つまりEasy LoginのLDAPを作るための開発者への賛辞!)
https://symfony.com/doc/3.3/components/security/authentication.html#authentication-events
私はAuthenticationEvents::AUTHENTICATION_SUCCESS
とSecurityEvents::INTERACTIVE_LOGIN
と試みたが、私のコードは間違っている、またはそれらのイベントがhttp_basic_ldap
のために解雇されていないのいずれか。
私のテストsrc/AppBundle/EventSubscriber/LoginSubscriber.php
:
namespace AppBundle\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Http\SecurityEvents;
class LoginSubscriber implements EventSubscriberInterface
{
public function onUserLogin ($dunno)
{
file_put_contents("/tmp/dunno.log", "yay, got called!\n", FILE_APPEND);
}
public static function getSubscribedEvents()
{
return [
AuthenticationEvents::AUTHENTICATION_SUCCESS => 'onUserLogin',
SecurityEvents::INTERACTIVE_LOGIN => 'onUserLogin',
];
}
}
PS。私の目標は、symfonyのデータベース/エンティティからユーザの役割をロードすることです(しかし、常にldapを使ってログインします)。