-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from magento-performance/cabpi-278-disable-po…
…st-to-old-login CABPI-278: Disable post to old login
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
app/code/Magento/AdminAdobeIms/Plugin/DisableAdminLoginAuthPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\AdminAdobeIms\Plugin; | ||
|
||
use Magento\AdminAdobeIms\Service\ImsConfig; | ||
use Magento\Backend\Model\Auth; | ||
use Magento\Framework\Controller\Result\Redirect; | ||
use Magento\Framework\Controller\Result\RedirectFactory; | ||
use Magento\Framework\Message\ManagerInterface as MessageManagerInterface; | ||
|
||
class DisableAdminLoginAuthPlugin | ||
{ | ||
/** @var ImsConfig */ | ||
private ImsConfig $imsConfig; | ||
|
||
/** @var RedirectFactory */ | ||
private RedirectFactory $redirectFactory; | ||
|
||
/** @var MessageManagerInterface */ | ||
private MessageManagerInterface $messageManager; | ||
|
||
/** | ||
* @param ImsConfig $imsConfig | ||
* @param RedirectFactory $redirectFactory | ||
* @param MessageManagerInterface $messageManager | ||
*/ | ||
public function __construct( | ||
ImsConfig $imsConfig, | ||
RedirectFactory $redirectFactory, | ||
MessageManagerInterface $messageManager | ||
) { | ||
$this->imsConfig = $imsConfig; | ||
$this->redirectFactory = $redirectFactory; | ||
$this->messageManager = $messageManager; | ||
} | ||
|
||
/** | ||
* When trying to call the login but IMS is enabled redirect to the main page with error message | ||
* | ||
* @param Auth $subject | ||
* @param callable $proceed | ||
* @param string $username | ||
* @param string $password | ||
* @return void | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundLogin(Auth $subject, callable $proceed, string $username, string $password): void | ||
{ | ||
if ($this->imsConfig->enabled() === false) { | ||
$proceed($username, $password); | ||
return; | ||
} | ||
|
||
/** @var Redirect $resultRedirect */ | ||
$resultRedirect = $this->redirectFactory->create(); | ||
$this->messageManager->addErrorMessage(__('Please sign in with Adobe ID')); | ||
$resultRedirect->setPath('admin'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters