Problem after get instance of User model

Hello,

This is the first post of me , hope I can help and get help from & to all.


I’m facing this problem

I installed Yii2 Advanced template

and separated (front-end & back-end) users

as in this link : http://www.yiiframework.com/wiki/814/guide-how-to-actually-separate-frontend-user-and-backend-admin-on-yii2-advanced/

also I need to control front-end users

so I add dektrium Yii2 user module to main.php in config folder in the back-end

I replaced ‘user’ by ‘player’





    'modules' => [


            'player' => [

            'class' => 'dektrium\user\Module',

            'enableRegistration' => false,

            'enableUnconfirmedLogin' => false,

            'confirmWithin' => 21600,

            'cost' => 12,

 'admins' => ['beadmin'],


        ],

 

    ],

sure I override views and replace ‘user’ variables

But when I request

index.php/player/admin

from back-end

I get following error

taking into considration that all things work well when just use ‘user’ instead of ‘player’ in main.php config file

like:

index.php/user/admin

in back-end

and this code





    'modules' => [


            'user' => [

            'class' => 'dektrium\user\Module',

            'enableRegistration' => false,

            'enableUnconfirmedLogin' => false,

            'confirmWithin' => 21600,

            'cost' => 12,

 'admins' => ['beadmin'],


        ],

 

    ],

Hoping I clarified my problem

Best Regards

Hi,

i already replied to this inquire in Arabic forum.

anyway to make this topic informative for community i will summarize my thoughts again here.

1st. in samdark’s wiki guide you mentioned above; i believe he was talking about separating the (default authentication of Yii2) NOT using (dektrium Yii2 user module)

so i guess you are mixing things here.

to separate users from front-end and back-end maybe you need to follow (dektrium Yii2 user module) documentation in this link:

Use independent sessions in one domain


2nd. to use:

index.php/player/admin

instead of

index.php/user/admin

all you need to deal with is Routing which lead you to urlManager and configure its rules in config.php file in backend:




'components' => [

  'urlManager' => [

    ...

	'rules' => [

      	'player/admin' => 'user/admin',

	],

    ...

  ],

],



the code above was in very basic form to clarify things up BUT at the same time it is not a sufficient solution since it is fixed routing. instead you need to tell Yii2 what is what in term of controller/action/variables. like in this example:




'rules' => [ 

  'player/<controller:\w+>' => 'user/<controller>', // route to controller

  'player/<controller:\w+>/<action:\w+>' =>  'user/<controller>/<action>', // route to action in a controller

  ...

  // the same idea should be done here for links with variables like in case of update and view.

  ...

],



For more information you can refer to URL Rules in Routing page in Yii2 documentation.

i hope this was informative for some one and solves what you were seeking for, thank you.