function getRecoveryCodes($userId)
{
    $codes = RecoveryCodesTable::getList(array('select' => array('CODE'), 'filter' => array('=USER_ID' => $userId, '=USED' => 'N')));
    $normalizedCodes = array();
    while ($code = $codes->fetch()) {
        $normalizedCodes[] = $code['CODE'];
    }
    return $normalizedCodes;
}
    ?>
				</div>
				<?php 
    echo EndNote();
    ?>
			</div>
		</td>
	</tr>
<?php 
} else {
    ?>
	<?php 
    if (Otp::isRecoveryCodesEnabled()) {
        ?>
		<?php 
        $codes = \Bitrix\Security\Mfa\RecoveryCodesTable::getList(array('select' => array('ID'), 'filter' => array('=USER_ID' => $ID), 'limit' => 1))->fetch();
        if (!$codes) {
            ?>
			<tr data-role="otp-recovery-codes-warning">
				<td colspan="2">
					<?php 
            CAdminMessage::ShowMessage(array("MESSAGE" => GetMessage('SEC_OTP_WARNING_RECOVERY_CODES'), "TYPE" => 'ERROR', "HTML" => true));
            ?>
				</td>
			</tr>
		<?php 
        }
        ?>
	<?php 
    }
    ?>
function getRecoveryCodes($userId, $isRegenerationAllowed = false)
{
    $codes = RecoveryCodesTable::getList(array('select' => array('CODE', 'USED', 'USING_DATE'), 'filter' => array('=USER_ID' => $userId)));
    $normalizedCodes = array();
    while ($code = $codes->fetch()) {
        /** @var Bitrix\Main\Type\DateTime $date */
        $date = $code['USING_DATE'];
        $normalizedCodes[] = array('value' => $code['CODE'], 'used' => $code['USED'] === 'Y', 'using_date' => $date ? $date->getTimestamp() : null);
    }
    if (empty($normalizedCodes) && $isRegenerationAllowed) {
        return regenerateRecoveryCodes($userId);
    } else {
        return array('status' => 'ok', 'codes' => $normalizedCodes);
    }
}