-
-
Save jmather/896294 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
protected $event = null; | |
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) | |
{ | |
$this->event = $event; | |
$username = $this->getUsername(); | |
$session = $this->getSession(); | |
$this->setFlash($session, $username); | |
} | |
protected function getUsername() | |
{ | |
return $this->event->getAuthenticationToken()->getUsername(); | |
} | |
protected function getSession() | |
{ | |
return $this->event->getRequest()->getSession(); | |
} | |
public function setFlash($event, $username) | |
{ | |
$session->setFlash('notice', "Welcome {$username}, you have successfully logged in."); | |
} |
This file contains hidden or 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
public function testOnSecurityInteractiveLogin() | |
{ | |
$loginEvent = new LoginListener(); | |
// Get a mock $event of type InteractiveLoginEvent | |
$loginEvent->onSecurityInteractiveLogin($event); | |
} | |
class LoginListenerStub extends LoginListener | |
{ | |
protected username = null; | |
protected session = null; | |
public setUsername($username) { $this->username = $username; } | |
public setSession($session) { $this->session = $session; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment