I'm trying to setup Aura.Auth with direct login and social sign in as well, but I'm facing problems when wiring things up. I got it working with just Facebook or direct login only. But when there is multiple providers I find it difficult to implement the Logout action. I have different login URL for each provider and a logout URL for all. Like,
In the application I've to pass aura:auth/login_service, aura:auth/logout_service and aura:auth/resume_service to the Auth. All of these services expect the adapter as a parameter. So I've to create adapter object to each provider and pass them to each service.
$di->set('facebookadapter', $di->lazyNew('MyApp\Auth\LeagueOAuth2Adapter',
['provider' => $di->lazyGet('facebookAuthProvider')]
));
$di->set('facebookLoginService', $di->lazyNew('Aura\Auth\Service\LoginService', [
'adapter' => $di->lazyGet('facebookadapter'),
'session' => $di->lazyGet('aura/auth:session')
]));
$di->set('facebook_auth_service', $di->lazyNew('MyApp\Domain\Service\AuthService', [
'auth' => $di->lazyGet('aura/auth:auth'),
'login_service' => $di->lazyGet('facebookLoginService'),
'resume_service' => $di->lazyGet('aura/auth:resume_service'),
'logout_service' => $di->lazyGet('aura/auth:logout_service')
]));
$di->params['MyApp\Action\User\FacebookLoginAction'] = [
'request' => $di->lazyGet('aura/web-kernel:request'),
'auth_service' => $di->get('facebook_auth_service'),
'user_service' => $di->lazyNew('MyApp\Domain\Service\UserService'),
'responder' => $di->lazyNew('MyApp\Responder\UserLoginResponder')
];
and so on..
This will work when I'm using different action for different auth provider, but is difficult to manage in the case of logout where there is only one action and I'm passing only one auth_service object
$di->params['MyApp\Action\User\LogoutAction'] = [
'request' => $di->lazyGet('aura/web-kernel:request'),
'auth_service' => $di->get('auth_service') // or facebook_auth_service, pdo_auth_service
];
I hope my question is clear. Can anyone suggest what is the best way to manage this? Or am I over-complicating things?