Skip to content

Instantly share code, notes, and snippets.

@angelxmoreno
Created October 25, 2019 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelxmoreno/21d6518cc404fd3b3680a5d6716725ef to your computer and use it in GitHub Desktop.
Save angelxmoreno/21d6518cc404fd3b3680a5d6716725ef to your computer and use it in GitHub Desktop.
<?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