예제 #1
1
function checkAndActivate($fields)
{
    try {
        $deferredParams = Otp::getDeferredParams();
        if (!$deferredParams['USER_ID']) {
            throw new \Bitrix\Security\Mfa\OtpException(Loc::getMessage('SECURITY_AUTH_OTP_MANDATORY_UNKNOWN_ERROR'));
        }
        $otp = Otp::getByUser($deferredParams['USER_ID']);
        $binarySecret = pack('H*', $fields['SECRET']);
        $otp->regenerate($binarySecret)->syncParameters($fields['SYNC1'], $fields['SYNC2'])->save();
        $deferredParams[Otp::REJECTED_KEY] = OTP::REJECT_BY_CODE;
        Otp::setDeferredParams($deferredParams);
        $result = array('status' => 'ok');
    } catch (\Bitrix\Security\Mfa\OtpException $e) {
        $result = array('status' => 'error', 'error' => $e->getMessage());
    }
    return $result;
}
예제 #2
0
 public static function OnAfterUserLogout()
 {
     /** @global \CMain $APPLICATION */
     global $APPLICATION;
     $APPLICATION->set_cookie(Otp::SKIP_COOKIE, '', false, '/', false, false, true, false, true);
     // Clear deferred params
     Otp::setDeferredParams(null);
 }