Issue: New user is not created when successfully authenticating with Facebook account. NOTE: I have setup a clean system from https://github.com/SocalNick/ScnSocialAuth [zip file download] and adjusted the Facebook ID and password from the Facebook Developer dashboard and this has successfully authenticated and created a new user in my user table and link in user_provider table. This is the issue that I'm pulling my hair out with as it works perfectly here but not in my customised application. Should be simple to compare but it's not...)
My ZF2 setup includes the Skeleton App, ZF 2.3x, ZfcUser, BjyAuthorise, ScnSocialAuth, Goalio(Mailservice and Password), Webino and my custom modules.
My Member module overrides the standard ZfcUser settings like so:
'zfcuser' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/account',
),
),
'scn-social-auth-user' => array(
'type' => 'Literal',
'options' => array(
'route' => '/account',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
),
'zfcuser' => array(
// telling ZfcUser to use our own class
'user_entity_class' => 'WMember\Entity\WMember',
// telling ZfcUserDoctrineORM to skip the entities it defines
'enable_default_entities' => false,
'table_name' => 'w_member',
'login_redirect_route' => 'account',
),
Along with some form customisations in the @/module/module.php to customise the ZFCForm
$sharedEvents->attach('ZfcUser\Form\Register',
'init',
function($e)
{
/* @var $form \ZfcUser\Form\Register */
$form = $e->getTarget();
I've successfully overwritten the views to include ScnSocialAuth and Zfcregistration. (issues discussed here: SFdot com/questions/31261580/zf2-scnsocialauth-hybridauth-zfcuser-and-routes )
The issue is that when I click on 'Facebook' under the 'Social Registration' /account/register i correctly get pushed to Facebook to login. (FB / login.php?skip_api_login=1&api_key=...) I log in and get pushed back to my application. This performs a few jumps and I end up back at the /account/login#= The 'few jumps' I'm talking about I can see in the Dev tools in chrome network. (cannot post image due to Rep < 10...) -- facebook.com/ajax/bz -- facebook.com/login.php?login_attempt=1&next=3A%2F%2Fwww.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%253A%252F%252Fmain.localtest.me%252Fscn-social-auth%252Fhauth%253Fhauth.done%25 -- facebook.com/v2.0/dialog/oauth?redirect_uri=3A%2F%2Fmain.localtest.me%2Fscn-social-auth%2Fhauth%3Fhauth.done% -- main.localtest.me/scn-social-auth/hauth?hauth.done=Facebook&code=AQC2MLK84QXAq0XW5gAgtWevuNAMSU-...
The debugging (extract) from ScnSocial log file is below:
INFO -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth::initialize(). PHP version: 5.4.27
INFO -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth::initialize(). Hybrid_Auth version: 2.4.1
INFO -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth::initialize(). Hybrid_Auth called from: main.localtest.me/scn-social-auth/hauth?hauth.done=Facebook&code=AQC2ML./...
DEBUG -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth initialize. dump used config: --
DEBUG -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth initialize. dump current session: --
a:3:{s:38:"hauth_session.facebook.hauth_return_to";s:38:"s:30:"/account/authenticate/facebook";";s:37:"hauth_session.facebook.hauth_endpoint";
-- main.localtest.me/scn-social-auth/hauth?hauth.done=Facebook --
INFO -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth initialize: check if any error is stored on the endpoint...
INFO -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth initialize: no error found. initialization succeed.
DEBUG -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Enter Hybrid_Auth::setup( Facebook ) --
DEBUG -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Hybrid_Auth::setup( Facebook ), no params given. Trying to get the stored for this provider. -- Array
(
[hauth_return_to] => /account/authenticate/facebook
[hauth_token] => vmj2li2q2bhln5np9ndc7shll6
[hauth_time] => 1437715061
[login_start] => main.localtest.me/scn-social-auth/hauth?hauth.start=Facebook&hauth.time=1437715061
[login_done] => main.localtest.me/scn-social-auth/hauth?hauth.done=Facebook
)
INFO -- 127.0.0.1 -- 2015-07-24T15:19:22+10:00 -- Enter Hybrid_Provider_Adapter::factory( Facebook )
DEBUG -- 127.0.0.1 -- 2015-07-24T15:19:23+10:00 -- Hybrid_Provider_Model::__construct( Facebook ) initialized. dump current adapter instance: --
O:25:"Hybrid_Providers_Facebook":7:{s:5:"scope";s:112:"email, user_about_me, user_birthday, user_hometown, user_website,
Any pointers here would be appreciated as I'm still learning the ins/outs of Zf2 and PHP 5.4+ closures, lamda funcs and DI in ZF2.
Again, the fundamental problem is that I cannot create a new user via the social registration. I have set the flag to 'true' even though it's default in sc-social-auth-global.php