• Модуль: security
  • Путь к файлу: ~/bitrix/modules/security/lib/mfa/recoverycodes.php
  • Класс: BitrixSecurityMfaRecoveryCodesTable
  • Вызов: RecoveryCodesTable::regenerateCodes
static function regenerateCodes($userId)
{
	$userId = (int) $userId;
	if ($userId <= 0)
		throw new ArgumentTypeException('userId', 'positive integer');

	static::clearByUser($userId);

	$randomVector = Random::getString(static::CODES_PER_USER * 8);
	$randomVector = str_split($randomVector, 4);
	for ($i = 0; $i < static::CODES_PER_USER; $i++)
	{
		$code = array(
			'USER_ID' => $userId,
			'USED' => 'N',
			'CODE' => sprintf('%s-%s', $randomVector[$i * 2], $randomVector[($i * 2) + 1])
		);

		static::add($code);
	}

	return true;
}