26 lines
521 B
PHP
26 lines
521 B
PHP
|
<?php
|
||
|
|
||
|
namespace app\modules\tgbot\middlewares;
|
||
|
|
||
|
use app\modules\tgbot\models\Tgbot;
|
||
|
use app\modules\tgbot\services\TgBotService;
|
||
|
use kernel\Middleware;
|
||
|
|
||
|
class TgBotAuthMiddleware extends Middleware
|
||
|
{
|
||
|
|
||
|
function handler(): void
|
||
|
{
|
||
|
if(isset($_COOKIE['dialog_id']))
|
||
|
{
|
||
|
$model = Tgbot::where("dialog_id", $_COOKIE['dialog_id'])->first();
|
||
|
if ($model){
|
||
|
TgBotService::$currentDialog = $model;
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
exit();
|
||
|
}
|
||
|
}
|