Created
October 25, 2019 18:20
-
-
Save angelxmoreno/21d6518cc404fd3b3680a5d6716725ef 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
<?php | |
public function getAuthenticationService(ServerRequestInterface $request, ResponseInterface $response) | |
{ | |
$service = new AuthenticationService(); | |
$fields = [ | |
'username' => 'email', | |
'password' => 'password' | |
]; | |
//set config | |
$service->setConfig([ | |
'unauthorizedRedirect' => ['controller' => 'Auth', 'action' => 'login'], | |
'queryParam' => 'redirect', | |
]); | |
// Load identifiers | |
$service->loadIdentifier('Authentication.Password', compact('fields')); | |
// Load the authenticators, you want session first | |
$service->loadAuthenticator('Authentication.Session'); | |
$service->loadAuthenticator('Authentication.Form', [ | |
'fields' => $fields, | |
'loginUrl' => ['controller' => 'Auth', 'action' => 'login'], | |
]); | |
return $service; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment