2025-01-23 20:02:06 +03:00
|
|
|
<?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
|
|
|
|
{
|
|
|
|
|
2025-01-26 14:42:47 +03:00
|
|
|
public function handler(): void
|
2025-01-23 20:02:06 +03:00
|
|
|
{
|
|
|
|
if(isset($_COOKIE['dialog_id']))
|
|
|
|
{
|
|
|
|
$model = Tgbot::where("dialog_id", $_COOKIE['dialog_id'])->first();
|
|
|
|
if ($model){
|
|
|
|
TgBotService::$currentDialog = $model;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit();
|
|
|
|
}
|
2025-01-26 14:42:47 +03:00
|
|
|
|
|
|
|
public function isTgAdmin(): void
|
|
|
|
{
|
|
|
|
if (TgBotService::isAdmin()){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Доступ запрещен";
|
|
|
|
exit();
|
|
|
|
}
|
2025-01-23 20:02:06 +03:00
|
|
|
}
|