How to login from different tables in Yii2

Comparing #10 with #11

Revision #11 was created by lenovo lenovo on May 7, 2020, 12:13:11 PM.

fix some typo

Content

The Problem: Yii2 utilizes by default UserIdentity configured in config/web.php for connection, this object apply one table to authentication ('identityClass' => 'app\painel\models\User'). How to authentication from diferent tables?
Solution:
Create instances in web.php to uses UserIdentify.
[...]
'loginUrl' => ['dashboard-teacher/login'],
'identityCookie' => [
'name' => '_pa
inelTeacher',
]
],
[...]
```

Model scho
lol:

```php
[...]
```php
<?php if (!\Yii::$app->scholl->isGuest):?>
<h1>My scho
lol Name: <?=\Yii::$app->scholl->identity->name?>
<?php endif;?>

<?php if (!\Yii::$app->teacher->isGuest):?>
<h1>Teacher Name: <?=\Yii::$app->teacher->identity->name?>
<?php endif;?>
[...]