2namespace Bitrix\Security\Mfa;
5use Bitrix\Main\ArgumentTypeException;
8use Bitrix\Main\Security\Random;
40 extends Entity\DataManager
52 return 'b_sec_recovery_codes';
65 'autocomplete' =>
true
72 'format' => static::CODE_PATTERN
75 'values' =>
array(
'Y',
'N'),
83 array(
'=this.USER_ID' =>
'ref.ID'),
84 array(
'join_type' =>
'INNER')
103 $codes = static::getList(
array(
104 'select' =>
array(
'ID'),
108 while ((
$code = $codes->fetch()))
110 static::delete(
$code[
'ID']);
132 $randomVector = Random::getString(static::CODES_PER_USER * 8);
133 $randomVector = str_split($randomVector, 4);
134 for (
$i = 0;
$i < static::CODES_PER_USER;
$i++)
139 'CODE' => sprintf(
'%s-%s', $randomVector[
$i * 2], $randomVector[(
$i * 2) + 1])
163 if (!preg_match(static::CODE_PATTERN, $searchCode))
164 throw new ArgumentTypeException(
'searchCode', sprintf(
'string, check pattern "%s"', static::CODE_PATTERN));
166 $codes = static::getList(
array(
167 'select' =>
array(
'ID',
'CODE'),
168 'filter' =>
array(
'=USER_ID' =>
$userId,
'=USED' =>
'N'),
172 while ((
$code = $codes->fetch()))
174 if(
$code[
'CODE'] === $searchCode)
179 'USING_IP' => \
Bitrix\
Main\Application::getInstance()->getContext()->getRequest()->getRemoteAddress()
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static useCode($userId, $searchCode)
static regenerateCodes($userId)
static clearByUser($userId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code