namespace MiniOrange\TwoFA\Controller\Account;
use Magento\Customer\Model\Account\Redirect as AccountRedirect;
use Magento\Framework\App\Action\Context;
use Magento\Customer\Model\Session;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Model\Url as CustomerUrl;
use Magento\Framework\Exception\EmailNotConfirmedException;
use Magento\Framework\Exception\AuthenticationException;
use Magento\Framework\Data\Form\FormKey\Validator;
use MiniOrange\TwoFA\Helper\TwoFAConstants;
use MiniOrange\TwoFA\Helper\TwoFAUtility;
use MiniOrange\TwoFA\Helper\MiniOrangeUser;
use MiniOrange\TwoFA\Helper\CustomEmail;
use Magento\Framework\App\ResponseInterface;
use MiniOrange\TwoFA\Helper\CustomSMS;
use Magento\Framework\Exception\State\UserLockedException;
class LoginPost extends \Magento\Customer\Controller\Account\LoginPost
{
private $cookieManager;
private $cookieMetadataFactory;
private $url;
private $moduleManager;
protected $customEmail;
protected $resultFactory;
protected $response;
protected $customSMS;
protected $customerUrl;
protected $TwoFAUtility;
protected $storeManager;
protected $session;
protected $customerAccountManagement;
protected $formKeyValidator;
protected $accountRedirect;
protected $_response;
public function __construct(Context $RM, Session $mI, AccountManagementInterface $gd, CustomerUrl $ua, Validator $WH, AccountRedirect $Y7, CustomEmail $Hm, CustomSMS $e4, TwoFAUtility $Wh, ResponseInterface $dK, \Magento\Framework\Controller\ResultFactory $S3, \Magento\Framework\Stdlib\CookieManagerInterface $zg, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $z6, \Magento\Framework\Module\Manager $hZ, \Magento\Framework\UrlInterface $Kq, \Magento\Store\Model\StoreManagerInterface $AL)
{
$this->session = $mI;
$this->customerAccountManagement = $gd;
$this->customerUrl = $ua;
$this->formKeyValidator = $WH;
$this->accountRedirect = $Y7;
$this->customEmail = $Hm;
$this->customSMS = $e4;
$this->TwoFAUtility = $Wh;
$this->cookieManager = $zg;
$this->cookieMetadataFactory = $z6;
$this->moduleManager = $hZ;
$this->url = $Kq;
$this->_response = $dK;
$this->resultFactory = $S3;
$this->storeManager = $AL;
parent::__construct($RM, $mI, $gd, $ua, $WH, $Y7);
}
public function execute()
{
$obgenLog = \Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class);
$obgenLog->info('in 2fa log');
$this->TwoFAUtility->log_debug("--------------------------------------------------Execute LoginPost:------------------------------------------------");
if (!($this->session->isLoggedIn() || !$this->formKeyValidator->validate($this->getRequest()))) {
$obgenLog->info('2fa not login');
goto Cr;
}
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("home");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("steps 1 ");
return $vW;
Cr:
if (!$this->getRequest()->isPost()) {
goto sR;
}
$IG = $this->getRequest()->getPost("login");
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$J2 = $this->storeManager->getStore()->getWebsiteId();
$this->TwoFAUtility->log_debug("steps 2 ");
$obgenLog->info('2fa not in CR');
if (!empty($IG["username"]) && !empty($IG["password"])) {
goto uW;
}
$this->TwoFAUtility->log_debug("Execute LoginPost: Username or password null");
$this->messageManager->addError(__("A login and a password are required."));
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
goto Th;
uW:
try {
$obgenLog->info('2fa not in login auth');
$Mx = $this->customerAccountManagement->authenticate($IG["username"], $IG["password"]);
$this->TwoFAUtility->log_debug("steps 3");
$nZ = $this->TwoFAUtility->getCustomerFromAttributes($IG["username"]);
$this->TwoFAUtility->log_debug("LoginPost.php : execute: getCustomerFromAttributes user_details group id", $nZ["group_id"]);
$this->TwoFAUtility->log_debug("LoginPost.php : execute: getCustomerFromAttributes user_details email", $nZ["email"]);
$Im = $this->TwoFAUtility->getGroupNameById($nZ["group_id"]);
$O5 = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::INVOKE_INLINE_REGISTERATION . $J2);
$eA = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ACTIVE_METHOD . $Im . $J2);
$oC = $eA == "[]" || $eA == NULL ? false : true;
$z9 = $this->TwoFAUtility->check2fa_enterprisePlan();
$obgenLog->info('2fa plan');
$obgenLog->info($O5." : ".$oC." : ".$z9);
$obgenLog->info($this->TwoFAUtility->checkTrustedIPs("customer"));
if ($O5 && $oC && $z9 && !$this->TwoFAUtility->checkTrustedIPs("customer")) {
goto tz;
}
$this->TwoFAUtility->log_debug("Execute LoginPost: Invoke Inline off");
$this->session->setCustomerDataAsLoggedIn($Mx);
$this->session->regenerateId();
goto DS;
tz:
$this->TwoFAUtility->log_debug("steps 4 coming in invokeinline ");
$this->TwoFAUtility->log_debug("Execute LoginPost: Inline Invoked and found active method");
$sB = $IG["username"];
$this->TwoFAUtility->setSessionValue("mousername", $IG["username"]);
$Hn = $this->cookieMetadataFactory->createPublicCookieMetadata();
$Hn->setDurationOneYear();
$Hn->setPath("/");
$Hn->setHttpOnly(false);
$this->cookieManager->setPublicCookie("mousername", $sB, $Hn);
$kI = $this->TwoFAUtility->getCustomerMoTfaUserDetails("miniorange_tfa_users", $sB);
$YR = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::CUSTOMER_REMEMBER_DEVICE . $J2);
if (!($YR && isset($kI) && !empty($kI) && isset($kI[0]["device_info"]) && $kI[0]["device_info"] != '')) {
goto bx;
}
$this->TwoFAUtility->log_debug("LoginPost.php : Inside device-based restriction check.");
$iP = json_decode($kI[0]["device_info"], true);
if (!(is_array($iP) && !empty($iP))) {
goto qG;
}
$this->TwoFAUtility->log_debug("LoginPost.php : Inside device-based restriction check, iterating through saved devices.");
$Ar = $this->TwoFAUtility->getCurrentDeviceInfo();
$Ar = json_decode($Ar, true);
$pf = (int) $this->TwoFAUtility->getStoreConfig(TwoFAConstants::CUSTOMER_REMEMBER_DEVICE_LIMIT . $J2);
$bG = date("Y-m-d");
$this->TwoFAUtility->log_debug("LoginPost.php : Device day limit: " . $pf);
foreach ($iP as $O_) {
$AF = true;
$Jy = ["Fingerprint"];
foreach ($Jy as $nQ) {
if (!(!isset($O_[$nQ]) || !isset($Ar[$nQ]) || $O_[$nQ] !== $Ar[$nQ])) {
goto l3;
}
$AF = false;
goto PH;
l3:
We:
}
PH:
if (!$AF) {
goto Pe;
}
$L7 = "device_info_" . md5($sB);
$Cm = $_COOKIE[$L7] ?? null;
if (!($Cm !== $O_["Random_string"])) {
goto Mf;
}
$this->TwoFAUtility->log_debug("LoginPost.php : cookies doesnt match with fingerprint");
$AF = false;
Mf:
Pe:
if (!$AF) {
goto ng;
}
$this->TwoFAUtility->log_debug("LoginPost.php : Device matches: " . $AF);
$mk = $O_["configured_date"];
$xf = (strtotime($bG) - strtotime($mk)) / (60 * 60 * 24);
if (!((int) $xf < (int) $pf)) {
goto SJ;
}
$this->TwoFAUtility->log_debug("LoginPost.php : Device matches and remaining days < device day limit. Device Day Limit: " . $pf);
$this->TwoFAUtility->log_debug("LoginPost.php : Device matches and remaining days < device day limit. Remaining Days: " . $xf);
$this->TwoFAUtility->log_debug("LoginPost.php : Device matches and remaining days < device day limit. Logging in without 2FA.");
$this->session->setCustomerDataAsLoggedIn($Mx);
$this->TwoFAUtility->log_debug("--------------------------------------------------Execute loginpost.php ended here for same device:------------------------------------------------");
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("customer/account");
$this->TwoFAUtility->log_debug("Current URL => ''(home) ");
return $vW;
SJ:
goto QX;
ng:
OG:
}
QX:
qG:
bx:
$eI = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::SKIP_TWOFA . $J2);
if (!($eI == 1)) {
goto Fv;
}
$bo = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::SKIP_TWOFA_DAYS . $J2);
if (!(!empty($kI) && isset($kI[0]["skip_twofa_premanent"]))) {
goto GF;
}
$dX = $kI[0]["skip_twofa_premanent"];
if (!($dX == true && $bo == "permanent")) {
goto kh;
}
$this->session->setCustomerDataAsLoggedIn($Mx);
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath('');
$on = $this->url->getCurrentUrl();
return $vW;
kh:
GF:
if (!(!empty($kI) && (isset($kI[0]["skip_twofa_configured_date"]) && $kI[0]["skip_twofa_configured_date"] != NULL))) {
goto Kg;
}
$Ga = json_decode($kI[0]["skip_twofa_configured_date"], true);
$mk = $Ga["configured_date"];
if (!($bo == "permanent")) {
goto jq;
}
$this->session->setCustomerDataAsLoggedIn($Mx);
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath('');
$this->TwoFAUtility->log_debug("Current URL => ''(home) ");
return $vW;
jq:
$bG = date("Y-m-d");
$xf = (strtotime($bG) - strtotime($mk)) / (60 * 60 * 24);
if (!($xf < (int) $bo)) {
goto vW;
}
$this->session->setCustomerDataAsLoggedIn($Mx);
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("customer/account");
$this->TwoFAUtility->log_debug("Current URL => ''(home) ");
return $vW;
vW:
Kg:
Fv:
$XN = '';
if (is_array($kI) && sizeof($kI) > 0 && (isset($kI[0]["skip_twofa"]) && ($kI[0]["skip_twofa"] == NULL || $kI[0]["skip_twofa"] == ''))) {
goto Kf;
}
$this->TwoFAUtility->log_debug("Execute LoginPost: Customer going through Inline");
$this->TwoFAUtility->log_debug("steps 5 coming in else part not found in database ");
$t7 = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::NUMBER_OF_CUSTOMER_METHOD . $Im . $J2);
if ($t7 == 1) {
goto uG;
}
if ($t7 > 1) {
goto Hk;
}
goto Qe;
uG:
$xL = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ACTIVE_METHOD . $Im . $J2);
$xL = trim($xL, "[""]");
$Fr = array("mopostoption" => "method", "miniorangetfa_method" => $xL, "inline_one_method" => "1", "email" => $sB);
$vW->setPath("motwofa/mocustomer", $Fr);
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
goto Qe;
Hk:
$Fr = array("mooption" => "invokeInline", "step" => "ChooseMFAMethod");
$vW->setPath("motwofa/mocustomer/index", $Fr);
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
Qe:
goto Gy;
Kf:
$this->TwoFAUtility->log_debug("Execute LoginPost: Customer has already registered in TwoFA method");
$Ra = $kI[0]["active_method"];
if ("GoogleAuthenticator" !== $Ra && "MicrosoftAuthenticator" !== $Ra) {
goto Z8;
}
$Fr = array("mooption" => "invokeTFA", "active_method" => $Ra);
$vW->setPath("motwofa/mocustomer/index", $Fr);
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
goto OV;
Z8:
$qI = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ENABLE_CUSTOMGATEWAY_EMAIL);
$tg = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ENABLE_CUSTOMGATEWAY_SMS);
$f0 = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ENABLE_CUSTOMGATEWAY_WHATSAPP);
if ($qI || $tg) {
goto qK;
}
if ($Ra == "OOW") {
goto rN;
}
$lD = new MiniOrangeUser();
$dK = json_decode($lD->challenge($sB, $this->TwoFAUtility, $Ra, true, $J2));
$Ys = array("status" => $dK->status, "message" => $dK->message, "txId" => $dK->txId);
goto lz;
rN:
if ($Ra == "OOW" && $f0) {
goto Sg;
}
if ($Ra == "OOW") {
goto ei;
}
goto V1;
Sg:
$Ba = $this->TwoFAUtility->Customgateway_GenerateOTP();
$ei = $kI[0]["phone"];
$z0 = $kI[0]["countrycode"];
$ei = $z0 . $ei;
$Ys = $this->TwoFAUtility->send_customgateway_whatsapp($ei, $Ba);
goto V1;
ei:
$Ba = $this->TwoFAUtility->Customgateway_GenerateOTP();
$ei = $kI[0]["phone"];
$z0 = $kI[0]["countrycode"];
$ei = $z0 . $ei;
$Ys = $this->TwoFAUtility->send_whatsapp($ei, $Ba);
V1:
lz:
goto rW;
qK:
$this->TwoFAUtility->log_debug("loginpost.php : execute: Custom gateway");
if ($Ra == "OOE" && $qI) {
goto kL;
}
if ($Ra == "OOE") {
goto Yv;
}
goto Tz;
kL:
$X4 = $this->TwoFAUtility->Customgateway_GenerateOTP();
$yd = $sB;
$Ys = $this->customEmail->sendCustomgatewayEmail($yd, $X4);
goto Tz;
Yv:
$lD = new MiniOrangeUser();
$dK = json_decode($lD->challenge($sB, $this->TwoFAUtility, $Ra, true, $J2));
$Ys = array("status" => $dK->status, "message" => $dK->message, "txId" => $dK->txId);
Tz:
if ($Ra == "OOS" && $tg) {
goto yj;
}
if ($Ra == "OOS") {
goto G3;
}
goto TI;
yj:
$Ba = $this->TwoFAUtility->Customgateway_GenerateOTP();
$ei = $kI[0]["phone"];
$z0 = $kI[0]["countrycode"];
$ei = "+" . $z0 . $ei;
$Ys = $this->customSMS->send_customgateway_sms($ei, $Ba);
goto TI;
G3:
$lD = new MiniOrangeUser();
$dK = json_decode($lD->challenge($sB, $this->TwoFAUtility, $Ra, true, $J2));
$Ys = array("status" => $dK->status, "message" => $dK->message, "txId" => $dK->txId);
TI:
if (!($Ra == "OOSE")) {
goto oB;
}
$X4 = $this->TwoFAUtility->Customgateway_GenerateOTP();
$yd = $sB;
$ei = $kI[0]["phone"];
$z0 = $kI[0]["countrycode"];
$ei = "+" . $z0 . $ei;
if ($qI) {
goto k6;
}
$jU["status"] = "FAILED";
goto Kz;
k6:
$jU = $this->customEmail->sendCustomgatewayEmail($yd, $X4);
Kz:
if ($tg) {
goto L_;
}
$Jc["status"] = "FAILED";
goto Nc;
L_:
$Jc = $this->customSMS->send_customgateway_sms($ei, $X4);
Nc:
$q2 = $this->TwoFAUtility->OTP_over_SMSandEMAIL_Message($yd, $ei, $jU["status"], $Jc["status"]);
if ($jU["status"] == "SUCCESS" || $Jc["status"] == "SUCCESS") {
goto w5;
}
$Ys = array("status" => "FAILED", "message" => $q2, "txId" => "1");
goto b9;
w5:
$Ys = array("status" => "SUCCESS", "message" => $q2, "txId" => "1");
b9:
oB:
$pH = 600;
if (!($Ys["status"] == "SUCCESS")) {
goto dp;
}
$Sq = time();
$wl = $Sq + $pH;
$this->TwoFAUtility->log_debug("LoginPost : otp expiry set for " . $wl);
$this->TwoFAUtility->setSessionValue("otp_expiry_time", $wl);
dp:
rW:
if ($Ys["status"] == "SUCCESS") {
goto O8;
}
$this->TwoFAUtility->log_debug("LoginPost.php : execute: Unable to send OTP for already configured users in miniorange_2fa_users.Please Contact your Administrator ");
$this->messageManager->addError(__("Unable to send OTP.Please Contact your Administrator"));
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("customer/account/login");
return $vW;
goto Sc;
O8:
$this->TwoFAUtility->updateColumnInTable("miniorange_tfa_users", "transactionId", $Ys["txId"], "username", $sB, $J2);
$Fr = array("mooption" => "invokeTFA", "message" => $Ys["message"], "r_status" => $Ys["status"], "active_method" => $Ra, "email" => $sB);
$vW->setPath("motwofa/mocustomer/index", $Fr);
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
return $vW;
Sc:
OV:
Gy:
return $vW;
DS:
} catch (EmailNotConfirmedException $k_) {
$Y1 = $this->customerUrl->getEmailConfirmationUrl($IG["username"]);
$q2 = __("This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.", $Y1);
$this->messageManager->addError($q2);
$this->session->setUsername($IG["username"]);
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
} catch (UserLockedException $e) {
$message = __(
'Your account login is disabled temporarily from invalid logins. Please contact Yummy Mummy Support.'
);
$this->messageManager->addError($message);
$this->session->setUsername($IG["username"]);
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
return $vW;
} catch (AuthenticationException $k_) {
$q2 = __("Invalid login or password.");
$this->messageManager->addError($q2);
$this->session->setUsername($IG["username"]);
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
} catch (\Exception $k_) {
$this->messageManager->addError(__("Invalid login or password."));
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
}
Th:
sR:
$obgenLog->info('in 2fa SR');
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("home");
$this->TwoFAUtility->log_debug("Current URL => home ");
return $vW;
}
}
namespace MiniOrange\TwoFA\Controller\Account;
use Magento\Customer\Model\Account\Redirect as AccountRedirect;
use Magento\Framework\App\Action\Context;
use Magento\Customer\Model\Session;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Model\Url as CustomerUrl;
use Magento\Framework\Exception\EmailNotConfirmedException;
use Magento\Framework\Exception\AuthenticationException;
use Magento\Framework\Data\Form\FormKey\Validator;
use MiniOrange\TwoFA\Helper\TwoFAConstants;
use MiniOrange\TwoFA\Helper\TwoFAUtility;
use MiniOrange\TwoFA\Helper\MiniOrangeUser;
use MiniOrange\TwoFA\Helper\CustomEmail;
use Magento\Framework\App\ResponseInterface;
use MiniOrange\TwoFA\Helper\CustomSMS;
use Magento\Framework\Exception\State\UserLockedException;
class LoginPost extends \Magento\Customer\Controller\Account\LoginPost
{
private $cookieManager;
private $cookieMetadataFactory;
private $url;
private $moduleManager;
protected $customEmail;
protected $resultFactory;
protected $response;
protected $customSMS;
protected $customerUrl;
protected $TwoFAUtility;
protected $storeManager;
protected $session;
protected $customerAccountManagement;
protected $formKeyValidator;
protected $accountRedirect;
protected $_response;
public function __construct(Context $RM, Session $mI, AccountManagementInterface $gd, CustomerUrl $ua, Validator $WH, AccountRedirect $Y7, CustomEmail $Hm, CustomSMS $e4, TwoFAUtility $Wh, ResponseInterface $dK, \Magento\Framework\Controller\ResultFactory $S3, \Magento\Framework\Stdlib\CookieManagerInterface $zg, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $z6, \Magento\Framework\Module\Manager $hZ, \Magento\Framework\UrlInterface $Kq, \Magento\Store\Model\StoreManagerInterface $AL)
{
$this->session = $mI;
$this->customerAccountManagement = $gd;
$this->customerUrl = $ua;
$this->formKeyValidator = $WH;
$this->accountRedirect = $Y7;
$this->customEmail = $Hm;
$this->customSMS = $e4;
$this->TwoFAUtility = $Wh;
$this->cookieManager = $zg;
$this->cookieMetadataFactory = $z6;
$this->moduleManager = $hZ;
$this->url = $Kq;
$this->_response = $dK;
$this->resultFactory = $S3;
$this->storeManager = $AL;
parent::__construct($RM, $mI, $gd, $ua, $WH, $Y7);
}
public function execute()
{
$obgenLog = \Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class);
$obgenLog->info('in 2fa log');
$this->TwoFAUtility->log_debug("--------------------------------------------------Execute LoginPost:------------------------------------------------");
if (!($this->session->isLoggedIn() || !$this->formKeyValidator->validate($this->getRequest()))) {
$obgenLog->info('2fa not login');
goto Cr;
}
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("home");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("steps 1 ");
return $vW;
Cr:
if (!$this->getRequest()->isPost()) {
goto sR;
}
$IG = $this->getRequest()->getPost("login");
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$J2 = $this->storeManager->getStore()->getWebsiteId();
$this->TwoFAUtility->log_debug("steps 2 ");
$obgenLog->info('2fa not in CR');
if (!empty($IG["username"]) && !empty($IG["password"])) {
goto uW;
}
$this->TwoFAUtility->log_debug("Execute LoginPost: Username or password null");
$this->messageManager->addError(__("A login and a password are required."));
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
goto Th;
uW:
try {
$obgenLog->info('2fa not in login auth');
$Mx = $this->customerAccountManagement->authenticate($IG["username"], $IG["password"]);
$this->TwoFAUtility->log_debug("steps 3");
$nZ = $this->TwoFAUtility->getCustomerFromAttributes($IG["username"]);
$this->TwoFAUtility->log_debug("LoginPostphp : execute: getCustomerFromAttributes user_details group id", $nZ["group_id"]);
$this->TwoFAUtility->log_debug("LoginPostphp : execute: getCustomerFromAttributes user_details email", $nZ["email"]);
$Im = $this->TwoFAUtility->getGroupNameById($nZ["group_id"]);
$O5 = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::INVOKE_INLINE_REGISTERATION . $J2);
$eA = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ACTIVE_METHOD . $Im . $J2);
$oC = $eA == "[]" || $eA == NULL ? false : true;
$z9 = $this->TwoFAUtility->check2fa_enterprisePlan();
$obgenLog->info('2fa plan');
$obgenLog->info($O5." : ".$oC." : ".$z9);
$obgenLog->info($this->TwoFAUtility->checkTrustedIPs("customer"));
if ($O5 && $oC && $z9 && !$this->TwoFAUtility->checkTrustedIPs("customer")) {
goto tz;
}
$this->TwoFAUtility->log_debug("Execute LoginPost: Invoke Inline off");
$this->session->setCustomerDataAsLoggedIn($Mx);
$this->session->regenerateId();
goto DS;
tz:
$this->TwoFAUtility->log_debug("steps 4 coming in invokeinline ");
$this->TwoFAUtility->log_debug("Execute LoginPost: Inline Invoked and found active method");
$sB = $IG["username"];
$this->TwoFAUtility->setSessionValue("mousername", $IG["username"]);
$Hn = $this->cookieMetadataFactory->createPublicCookieMetadata();
$Hn->setDurationOneYear();
$Hn->setPath("/");
$Hn->setHttpOnly(false);
$this->cookieManager->setPublicCookie("mousername", $sB, $Hn);
$YR = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::CUSTOMER_REMEMBER_DEVICE . $J2);
if (!($YR && isset($kI) && !empty($kI) && isset("$"["device_info"]) && "$"["device_info"] != '')) {
goto bx;
}
$this->TwoFAUtility->log_debug("LoginPostphp : Inside device-based restriction check.");
$iP = json_decode("$"["device_info"], true);
if (!(is_array($iP) && !empty($iP))) {
goto qG;
}
$this->TwoFAUtility->log_debug("LoginPostphp : Inside device-based restriction check, iterating through saved devices.");
$Ar = $this->TwoFAUtility->getCurrentDeviceInfo();
$Ar = json_decode($Ar, true);
$pf = (int) $this->TwoFAUtility->getStoreConfig(TwoFAConstants::CUSTOMER_REMEMBER_DEVICE_LIMIT . $J2);
$bG = date("Y-m-d");
$this->TwoFAUtility->log_debug("LoginPostphp : Device day limit: " . $pf);
foreach ($iP as $O_) {
$AF = true;
$Jy = ["Fingerprint"];
foreach ($Jy as $nQ) {
if (!(!isset($O_[$nQ]) || !isset($Ar[$nQ]) || $O_[$nQ] !== $Ar[$nQ])) {
goto l3;
}
$AF = false;
goto PH;
l3:
We:
}
PH:
if (!$AF) {
goto Pe;
}
$L7 = "device_info_" . md5($sB);
$Cm = $_COOKIE[$L7] ?? null;
if (!($Cm !== $O_["Random_string"])) {
goto Mf;
}
$this->TwoFAUtility->log_debug("LoginPostphp : cookies doesnt match with fingerprint");
$AF = false;
Mf:
Pe:
if (!$AF) {
goto ng;
}
$this->TwoFAUtility->log_debug("LoginPostphp : Device matches: " . $AF);
$mk = $O_["configured_date"];
$xf = (strtotime($bG) - strtotime($mk)) / (60 * 60 * 24);
if (!((int) $xf < (int) $pf)) {
goto SJ;
}
$this->TwoFAUtility->log_debug("LoginPostphp : Device matches and remaining days < device day limitDevice Day Limit: " . $pf);
$this->TwoFAUtility->log_debug("LoginPostphp : Device matches and remaining days < device day limitRemaining Days: " . $xf);
$this->TwoFAUtility->log_debug("LoginPostphp : Device matches and remaining days < device day limitLogging in without 2FA.");
$this->session->setCustomerDataAsLoggedIn($Mx);
$this->TwoFAUtility->log_debug("--------------------------------------------------Execute loginpostphp ended here for same device:------------------------------------------------");
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("customer/account");
$this->TwoFAUtility->log_debug("Current URL => ''(home) ");
return $vW;
SJ:
goto QX;
ng:
OG:
}
QX:
qG:
bx:
$eI = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::SKIP_TWOFA . $J2);
if (!($eI == 1)) {
goto Fv;
}
$bo = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::SKIP_TWOFA_DAYS . $J2);
if (!(!empty($kI) && isset("$"["skip_twofa_premanent"]))) {
goto GF;
}
$dX = "$"["skip_twofa_premanent"];
if (!($dX == true && $bo == "permanent")) {
goto kh;
}
$this->session->setCustomerDataAsLoggedIn($Mx);
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath('');
$on = $this->url->getCurrentUrl();
return $vW;
kh:
GF:
if (!(!empty($kI) && (isset("$"["skip_twofa_configured_date"]) && "$"["skip_twofa_configured_date"] != NULL))) {
goto Kg;
}
$Ga = json_decode("$"["skip_twofa_configured_date"], true);
$mk = $Ga["configured_date"];
if (!($bo == "permanent")) {
goto jq;
}
$this->session->setCustomerDataAsLoggedIn($Mx);
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath('');
$this->TwoFAUtility->log_debug("Current URL => ''(home) ");
return $vW;
jq:
$bG = date("Y-m-d");
$xf = (strtotime($bG) - strtotime($mk)) / (60 * 60 * 24);
if (!($xf < (int) $bo)) {
goto vW;
}
$this->session->setCustomerDataAsLoggedIn($Mx);
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("customer/account");
$this->TwoFAUtility->log_debug("Current URL => ''(home) ");
return $vW;
vW:
Kg:
Fv:
$XN = '';
if (is_array($kI) && sizeof($kI) > 0 && (isset("$"["skip_twofa"]) && ("$"["skip_twofa"] == NULL || "$"["skip_twofa"] == ''))) {
goto Kf;
}
$this->TwoFAUtility->log_debug("Execute LoginPost: Customer going through Inline");
$this->TwoFAUtility->log_debug("steps 5 coming in else part not found in database ");
$t7 = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::NUMBER_OF_CUSTOMER_METHOD . $Im . $J2);
if ($t7 == 1) {
goto uG;
}
if ($t7 > 1) {
goto Hk;
}
goto Qe;
uG:
$xL = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ACTIVE_METHOD . $Im . $J2);
$xL = trim($xL, "[""]");
$Fr = array("mopostoption" => "method", "miniorangetfa_method" => $xL, "inline_one_method" => "1", "email" => $sB);
$vW->setPath("motwofa/mocustomer", $Fr);
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
goto Qe;
Hk:
$Fr = array("mooption" => "invokeInline", "step" => "ChooseMFAMethod");
$vW->setPath("motwofa/mocustomer/index", $Fr);
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
Qe:
goto Gy;
Kf:
$this->TwoFAUtility->log_debug("Execute LoginPost: Customer has already registered in TwoFA method");
$Ra = "$"["active_method"];
if ("GoogleAuthenticator" !== $Ra && "MicrosoftAuthenticator" !== $Ra) {
goto Z8;
}
$Fr = array("mooption" => "invokeTFA", "active_method" => $Ra);
$vW->setPath("motwofa/mocustomer/index", $Fr);
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
goto OV;
Z8:
$qI = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ENABLE_CUSTOMGATEWAY_EMAIL);
$tg = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ENABLE_CUSTOMGATEWAY_SMS);
$f0 = $this->TwoFAUtility->getStoreConfig(TwoFAConstants::ENABLE_CUSTOMGATEWAY_WHATSAPP);
if ($qI || $tg) {
goto qK;
}
if ($Ra == "OOW") {
goto rN;
}
$lD = new MiniOrangeUser();
$dK = json_decode($lD->challenge($sB, $this->TwoFAUtility, $Ra, true, $J2));
$Ys = array("status" => $dK->status, "message" => $dK->message, "txId" => $dK->txId);
goto lz;
rN:
if ($Ra == "OOW" && $f0) {
goto Sg;
}
if ($Ra == "OOW") {
goto ei;
}
goto V1;
Sg:
$Ba = $this->TwoFAUtility->Customgateway_GenerateOTP();
$ei = "$"["phone"];
$z0 = "$"["countrycode"];
$ei = $z0 . $ei;
$Ys = $this->TwoFAUtility->send_customgateway_whatsapp($ei, $Ba);
goto V1;
ei:
$Ba = $this->TwoFAUtility->Customgateway_GenerateOTP();
$ei = "$"["phone"];
$z0 = "$"["countrycode"];
$ei = $z0 . $ei;
$Ys = $this->TwoFAUtility->send_whatsapp($ei, $Ba);
V1:
lz:
goto rW;
qK:
$this->TwoFAUtility->log_debug("loginpostphp : execute: Custom gateway");
if ($Ra == "OOE" && $qI) {
goto kL;
}
if ($Ra == "OOE") {
goto Yv;
}
goto Tz;
kL:
$X4 = $this->TwoFAUtility->Customgateway_GenerateOTP();
$yd = $sB;
$Ys = $this->customEmail->sendCustomgatewayEmail($yd, $X4);
goto Tz;
Yv:
$lD = new MiniOrangeUser();
$dK = json_decode($lD->challenge($sB, $this->TwoFAUtility, $Ra, true, $J2));
$Ys = array("status" => $dK->status, "message" => $dK->message, "txId" => $dK->txId);
Tz:
if ($Ra == "OOS" && $tg) {
goto yj;
}
if ($Ra == "OOS") {
goto G3;
}
goto TI;
yj:
$Ba = $this->TwoFAUtility->Customgateway_GenerateOTP();
$ei = "$"["phone"];
$z0 = "$"["countrycode"];
$ei = "+" . $z0 . $ei;
$Ys = $this->customSMS->send_customgateway_sms($ei, $Ba);
goto TI;
G3:
$lD = new MiniOrangeUser();
$dK = json_decode($lD->challenge($sB, $this->TwoFAUtility, $Ra, true, $J2));
$Ys = array("status" => $dK->status, "message" => $dK->message, "txId" => $dK->txId);
TI:
if (!($Ra == "OOSE")) {
goto oB;
}
$X4 = $this->TwoFAUtility->Customgateway_GenerateOTP();
$yd = $sB;
$ei = "$"["phone"];
$z0 = "$"["countrycode"];
$ei = "+" . $z0 . $ei;
if ($qI) {
goto k6;
}
$jU["status"] = "FAILED";
goto Kz;
k6:
$jU = $this->customEmail->sendCustomgatewayEmail($yd, $X4);
Kz:
if ($tg) {
goto L_;
}
$Jc["status"] = "FAILED";
goto Nc;
L_:
$Jc = $this->customSMS->send_customgateway_sms($ei, $X4);
Nc:
$q2 = $this->TwoFAUtility->OTP_over_SMSandEMAIL_Message($yd, $ei, $jU["status"], $Jc["status"]);
if ($jU["status"] == "SUCCESS" || $Jc["status"] == "SUCCESS") {
goto w5;
}
$Ys = array("status" => "FAILED", "message" => $q2, "txId" => "1");
goto b9;
w5:
$Ys = array("status" => "SUCCESS", "message" => $q2, "txId" => "1");
b9:
oB:
$pH = 600;
if (!($Ys["status"] == "SUCCESS")) {
goto dp;
}
$Sq = time();
$wl = $Sq + $pH;
$this->TwoFAUtility->log_debug("LoginPost : otp expiry set for " . $wl);
$this->TwoFAUtility->setSessionValue("otp_expiry_time", $wl);
dp:
rW:
if ($Ys["status"] == "SUCCESS") {
goto O8;
}
$this->TwoFAUtility->log_debug("LoginPostphp : execute: Unable to send OTP for already configured users in miniorange_2fa_usersPlease Contact your Administrator ");
$this->messageManager->addError(__("Unable to send OTPPlease Contact your Administrator"));
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("customer/account/login");
return $vW;
goto Sc;
O8:
$this->TwoFAUtility->updateColumnInTable("miniorange_tfa_users", "transactionId", $Ys["txId"], "username", $sB, $J2);
$Fr = array("mooption" => "invokeTFA", "message" => $Ys["message"], "r_status" => $Ys["status"], "active_method" => $Ra, "email" => $sB);
$vW->setPath("motwofa/mocustomer/index", $Fr);
$this->TwoFAUtility->log_debug("Current URL => loginpost to motwofa/mocustomer/index ");
return $vW;
Sc:
OV:
Gy:
return $vW;
DS:
} catch (EmailNotConfirmedException $k_) {
$Y1 = $this->customerUrl->getEmailConfirmationUrl($IG["username"]);
$q2 = __("This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.", $Y1);
$this->messageManager->addError($q2);
$this->session->setUsername($IG["username"]);
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
} catch (UserLockedException $e) {
$message = __(
'Your account login is disabled temporarily from invalid loginsPlease contact Yummy Mummy Support.'
);
$this->messageManager->addError($message);
$this->session->setUsername($IG["username"]);
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
return $vW;
} catch (AuthenticationException $k_) {
$q2 = __("Invalid login or password.");
$this->messageManager->addError($q2);
$this->session->setUsername($IG["username"]);
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
} catch (\Exception $k_) {
$this->messageManager->addError(__("Invalid login or password."));
$vW->setPath("customer/account/login");
$on = $this->url->getCurrentUrl();
$this->TwoFAUtility->log_debug("Current URL => customer/account/login ");
return $vW;
}
Th:
sR:
$obgenLog->info('in 2fa SR');
$vW = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$vW->setPath("home");
$this->TwoFAUtility->log_debug("Current URL => home ");
return $vW;
}
}
© 2023 Quttera Ltd. All rights reserved.