This is actually the correct way to do it and to work around this "Problem" is to declare different sessions for your frontend and backend.
Yii2 advanced template has this feature included in the stock and I would suggest you not to start inventing the wheel again and just move your project to the advanced template.
Ofcourse you can create a new model and a new table for just the admins. However this new class should still implement IdentityInterface
Something where your AdminUserModel looks something like this:
namespace app\models;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface
class AdminUser extends ActiveRecord implements IdentityInterface
{
/** Dont froget all the related stuff like behaviours, properties etc **/
/**
* @inheritdoc
*/
public static function tableName()
{
return 'admin_user';
}
public static function findIdentity($id)
{
return static::findOne($id);
}
public static function findIdentityByAccessToken($token, $type = null)
{
return static::findOne(['access_token' => $token]);
}
public function getId()
{
return $this->id;
}
public function getAuthKey()
{
return $this->authKey;
}
public function validateAuthKey($authKey)
{
return $this->authKey === $authKey;
}
}
And if you decide to go this route, I would even suggest you to extend regular User model in AdminUser model, since a lot of the properties and functionality will be the same.