Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ class Config extends AbstractHelper
*/
const XML_PATH_BOLT_SSO = 'payment/boltpay/bolt_sso';

/**
* Enable Bolt SSO redirect referer
*/
const XML_PATH_BOLT_SSO_REDIRECT_REFERER = 'payment/boltpay/bolt_sso_redirect_referer';

/**
* Enable Bolt Universal debug requests
*/
Expand Down Expand Up @@ -2237,6 +2242,22 @@ public function isBoltSSOEnabled($storeId = null)
);
}

/**
* Get config value for whether or not Bolt SSO redirect referer is enabled
*
* @param int|string|Store $storeId
*
* @return boolean
*/
public function isBoltSSORedirectRefererEnabled($storeId = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_BOLT_SSO_REDIRECT_REFERER,
ScopeInterface::SCOPE_STORE,
$storeId
);
}

/**
* Get config value for whether or not Bolt Debug V2 is enabled.
*
Expand Down
33 changes: 32 additions & 1 deletion Model/Api/OAuthRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Bolt\Boltpay\Helper\Log as LogHelper;
use Bolt\Boltpay\Helper\Session as SessionHelper;
use Bolt\Boltpay\Helper\SSOHelper;
use Bolt\Boltpay\Helper\Config;
use Exception;
use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository;
use Magento\Customer\Api\Data\CustomerInterface;
Expand All @@ -49,6 +50,7 @@
use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\App\PageCache\FormKey as CookieFormKey;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\App\Response\RedirectInterface;

class OAuthRedirect implements OAuthRedirectInterface
{
Expand Down Expand Up @@ -162,12 +164,31 @@ class OAuthRedirect implements OAuthRedirectInterface
*/
private $cartRepository;

/**
* @var SessionConfigInterface
*/
private $sessionConfig;

/**
* @var FormKey
*/
private $formKey;

/**
* @var CookieFormKey
*/
private $cookieFormKey;

/**
* @var Config
*/
private $config;

/**
* @var RedirectInterface
*/
private $redirect;

/**
* @param Response $response
* @param DeciderHelper $deciderHelper
Expand All @@ -192,6 +213,8 @@ class OAuthRedirect implements OAuthRedirectInterface
* @param SessionConfigInterface $sessionConfig
* @param FormKey $formKey
* @param CookieFormKey $cookieFormKey
* @param Config $config
* @param RedirectInterface $redirect
*/
public function __construct(
Response $response,
Expand All @@ -216,7 +239,9 @@ public function __construct(
CartRepositoryInterface $cartRepository,
SessionConfigInterface $sessionConfig,
FormKey $formKey,
CookieFormKey $cookieFormKey
CookieFormKey $cookieFormKey,
Config $config,
RedirectInterface $redirect
) {
$this->response = $response;
$this->deciderHelper = $deciderHelper;
Expand All @@ -241,6 +266,8 @@ public function __construct(
$this->sessionConfig = $sessionConfig;
$this->formKey = $formKey;
$this->cookieFormKey = $cookieFormKey;
$this->config = $config;
$this->redirect = $redirect;
}

/**
Expand Down Expand Up @@ -531,6 +558,10 @@ private function linkLoginAndRedirect($externalID, $customerID)
}
}

if ($this->config->isBoltSSORedirectRefererEnabled() && ($referer = $this->redirect->getRefererUrl())) {
$redirectUrl = $referer;
}

$this->response->setRedirect($redirectUrl)->sendResponse();
}

Expand Down
7 changes: 7 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@
<config_path>payment/boltpay/bolt_sso</config_path>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="bolt_sso_redirect_referer" translate="label" type="select" sortOrder="85" showInDefault="1" showInWebsite="1" showInStore="0">
<label>(BETA) SSO Redirect To Previous Page</label>
<depends><field id="bolt_sso">1</field></depends>
<comment>Redirects customer to the previous page after successful SSO login</comment>
<config_path>payment/boltpay/bolt_sso_redirect_referer</config_path>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="disabled_customer_groups" translate="label comment" type="multiselect" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Disable for Customer Groups</label>
<comment>Chosen customer groups won't be able to use Bolt</comment>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ tr.shipping.totals td.amount span.price,
<enable_store_pickup_feature>0</enable_store_pickup_feature>
<always_present_checkout>0</always_present_checkout>
<bolt_sso>0</bolt_sso>
<bolt_sso_redirect_referer>0</bolt_sso_redirect_referer>
<universal_debug>1</universal_debug>
<aheadworks_reward_points_on_cart>1</aheadworks_reward_points_on_cart>
<mageworx_reward_points_on_cart>1</mageworx_reward_points_on_cart>
Expand Down