namespace MiniOrange\IDPSaml\Controller\Actions;
use MiniOrange\IDPSaml\Helper\Curl;
use MiniOrange\IDPSaml\Helper\IDPConstants;
use MiniOrange\IDPSaml\Helper\IDPMessages;
use MiniOrange\IDPSaml\Helper\Exception\AccountAlreadyExistsException;
use MiniOrange\IDPSaml\Exception\NotRegisteredException;
class LoginExistingUserAction extends BaseAdminAction
{
public function execute()
{
$this->checkIfRequiredFieldsEmpty(["email" => $this->REQUEST, "password" => $this->REQUEST, "submit" => $this->REQUEST]);
$Wc = $this->REQUEST["email"];
$u0 = $this->REQUEST["password"];
$aP = $this->REQUEST["submit"];
$this->getCurrentCustomer($Wc, $u0);
$this->idpUtility->flushCache();
}
private function getCurrentCustomer($Wc, $u0)
{
$Ib = Curl::get_customer_key($Wc, $u0);
$sK = json_decode($Ib, true);
if (isset($sK["status"]) && $sK["status"] == "SUCCESS") {
goto Rp;
}
$this->idpUtility->setStoreConfig(IDPConstants::REG_STATUS, '');
$this->getMessageManager()->addErrorMessage(IDPMessages::ACCOUNT_EXISTS);
goto Rx;
Rp:
$this->idpUtility->setStoreConfig(IDPConstants::SAML_IDP_EMAIL, $Wc);
$this->idpUtility->setStoreConfig(IDPConstants::SAML_IDP_KEY, $sK["id"]);
$this->idpUtility->setStoreConfig(IDPConstants::API_KEY, $sK["apiKey"]);
$this->idpUtility->setStoreConfig(IDPConstants::TOKEN, $sK["token"]);
$this->idpUtility->setStoreConfig(IDPConstants::TXT_ID, '');
$this->idpUtility->setStoreConfig(IDPConstants::REG_STATUS, IDPConstants::STATUS_COMPLETE_LOGIN);
$this->getMessageManager()->addSuccessMessage(IDPMessages::REG_SUCCESS);
Rx:
}
}
© 2023 Quttera Ltd. All rights reserved.