M
M
Maxim Ustinov2016-10-10 19:33:03
Yii
Maxim Ustinov, 2016-10-10 19:33:03

Separate IdentityInterface for module in Yii2?

Hello!
Is it possible to make a separate authorization for the module in a separate table in the database in the basic template?
Thanks to all.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2016-10-10
@fornit1917

Really. Did. In the init function in the module class, you need to write something like this:

Yii::$app->set('user', [
            'class' => 'yii\Web\User',
            'identityCookie' => ['name' => '_adm', 'httpOnly' => true],
            'idParam' => '__adm_id',
            'identityClass'  => 'app\modules\admin\models\Admin',
            'loginUrl' => ['admin/auth/login'],
            'enableAutoLogin' => true
        ]);

Those. for the user component, specify the IdentityClass we need. Well, all sorts of prefixes for cookies so that they don’t intersect with the main site

K
Konstantin B., 2016-11-06
@Kostik_1993

It's probably not the object
Try to write
<?php echo $item->name ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question