0

Using ZF2 to customise an Entity based on ZfcUser. Trying to use ScnSocialAuth and got a bit of a problem. The problem is that I am using custom routes ('/account' instead of '/user') and when implementing ScnSocialAuth I cannot get the social code into my custom zfcuser view...? I have \\view\zfc-user\user\register.php which overrides the zfcuser registration. I have a customised route:

'account' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                        'route' => '/account',
                ),
        ),

These are my zfc config modification within \my-module\config\module.config.php

    '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',
),

My global \config\application.config.php

'ScnSocialAuth',
'MyModule1',
'ZfcBase',
'ZfcUser',
'BjyAuthorize',
'GoalioMailService',
'GoalioForgotPassword',
'my-user-module',

Therefore, after all this:

  1. I can see my own extended User registration form by navigating to /account/register with no Social login links visible
  2. I can see the ScnSocialAuth when navigating to /user/register

a) I cannot create the view in my module to override \vendor\scn-social-auth\user\register.phtml as was done with zfcuser

Please help with getting ScnSocialAuth to work with my custom route setup. If this is just wrong please let me know as I'm not ZF2 expert. Happy to take 'constructive' criticism.

Saw these posts: How to (correctly) extend ScnSocialAuth\Authentication\Adapter\HybridAuth::authenticate() method? and this as a result of the above post: https://github.com/SocalNick/ScnSocialAuth/issues/202

NOTE: still running ZF-2.3* due to PHP 5.3,5.4

Community
  • 1
  • 1
JI-Web
  • 481
  • 6
  • 27
  • NOTE: I can explicitly override the view with ['template_map']['zfc-user/user/register'] => __DIR__ path to my view file. Once this is done I receive "Fatal error: Call to a member function getEnabledProviders() " and it appears that this view helper is not available? $this->options->getEnabledProviders() – JI-Web Jul 07 '15 at 06:58

1 Answers1

0

Instead of adding a custom route to your config, you need to over-ride the zfcuser route

<?php
// @file MyUserModule/config/module.config.php
return array(
    // other config ...

    'router' => array(
         'routes' => array(
            'zfcuser' => array(
                'options' => array(
                    // this is the only change needed to route zfcuser to /account
                    'route' => '/account',
                ),
            ),
         ),
     ),

     // more config ...
);

The ScnSocialAuth module uses the forward() plugin to render the content from zfcusers register view (and login view iirc), which means it will only ever look at the zfcuser route and completely ignore your custom route. The only way to have it use your custom route would be to replace ScnSocialAuths UserController with your own using identical code but forwarding to your custom route (much more work there, and still the potential to break anything else that expects zfcuser to be the route used)

Crisp
  • 11,417
  • 3
  • 38
  • 41
  • Thanks Crisp for the quick reply. Unfortunately I already had this in my @file MyUserModule/config/module.config.php config array. ' 'router' => array( 'routes' => array( // Start to overwrite zfcuser's route 'zfcuser' => array( // 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/account', ), ), ' After removing the "literal" from the config It still seems that this solution might require a fallback to the 'user' route instead of 'account' – JI-Web Jul 07 '15 at 23:52
  • Looks like an answer from the module developer got me closer: Override the config key for: scn-social-auth-user with 'route' set to the custom route you're trying to get to. This along with the above mentioned zfcuser adjustment seems to get there. NOW I have another issue with zfcuser registrations and even when remvoing the scn-social module I now cannot register ( Statement could not be executed (42S22 - 1054 - Unknown column 'array_copy' in 'field list') ) ... another error to resolve... – JI-Web Jul 24 '15 at 01:19