Initial commit: Auth Server Base
This commit is contained in:
38
local/modules/conmed.authserver/lib/api.php
Normal file
38
local/modules/conmed.authserver/lib/api.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Conmed\Authserver;
|
||||
|
||||
/**
|
||||
* Класс-фасад API сервера авторизации
|
||||
* Собирает функционал из трейтов и содержит системные методы (агенты)
|
||||
*/
|
||||
class Api {
|
||||
// ВНИМАТЕЛЬНО: Подключаем все 7 трейтов
|
||||
use SecurityTrait, AuthTokenTrait, RegistrationTrait, ProfileTrait, GroupsTrait, DictionariesTrait, CredentialsTrait, InternalDataTrait;
|
||||
|
||||
public static function onAfterUserDeleteHandler($userId) {
|
||||
Webhook::sendDelete($userId);
|
||||
}
|
||||
|
||||
public static function cleanLogsAgent() {
|
||||
if (!\Bitrix\Main\Loader::includeModule("highloadblock")) return "";
|
||||
try {
|
||||
$dcSec = self::getHlEntity('sso_security_log');
|
||||
$dcAud = self::getHlEntity('sso_audit');
|
||||
$dcCodes = self::getHlEntity('sso_codes');
|
||||
|
||||
$date7 = \Bitrix\Main\Type\DateTime::createFromTimestamp(time() - 86400 * 7);
|
||||
$rs = $dcSec::getList(['filter' => ['<UF_DATE' => $date7], 'select' => ['ID']]);
|
||||
while ($el = $rs->fetch()) $dcSec::delete($el['ID']);
|
||||
|
||||
$date60 = \Bitrix\Main\Type\DateTime::createFromTimestamp(time() - 86400 * 60);
|
||||
$rs = $dcAud::getList(['filter' => ['<UF_DATE' => $date60], 'select' => ['ID']]);
|
||||
while ($el = $rs->fetch()) $dcAud::delete($el['ID']);
|
||||
|
||||
$date1h = \Bitrix\Main\Type\DateTime::createFromTimestamp(time() - 3600);
|
||||
$rs = $dcCodes::getList(['filter' => ['<UF_EXPIRES' => $date1h], 'select' => ['ID']]);
|
||||
while ($el = $rs->fetch()) $dcCodes::delete($el['ID']);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return "\Conmed\Authserver\Api::cleanLogsAgent();";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user