Revision #11 has been created by lenovo on May 7, 2020, 12:13:11 PM with the memo:
fix some typo
« previous (#10)
Changes
Title
unchanged
How to login from different tables in Yii2
Category
unchanged
How-tos
Yii version
unchanged
2.0
Tags
unchanged
authentication,login,different table name,multiple login
Content
changed
The Problem:
Yii2 utilizes by default UserIdentity configured in config/web.php for connection, this object app
ly one table to authentication ('identityClass' => 'app\pa
inel\models\User'). How to authentication from diferent tables?
Solution:
Create instances in web.php to uses UserIdentify.[...]
'loginUrl' => ['dashboard-teacher/login'],
'identityCookie' => [
'name' => '_painelTeacher',
]
],[...]
```
Model scholol:
```php[...]
```php
<?php if (!\Yii::$app->scholl->isGuest):?>
<h1>My scholol Name: <?=\Yii::$app->scholl->identity->name?>
<?php endif;?>
<?php if (!\Yii::$app->teacher->isGuest):?>
<h1>Teacher Name: <?=\Yii::$app->teacher->identity->name?>
<?php endif;?>[...]