-
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 #342 from magento-extensibility/MAGETWO-38635-prs
[Extensibility] Magetwo 38635 prs
- Loading branch information
Showing
82 changed files
with
6,803 additions
and
21 deletions.
There are no files selected for viewing
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
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
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,44 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Security\Block\Adminhtml\Js; | ||
|
||
/** | ||
* Block Session Checker | ||
*/ | ||
class Checker extends \Magento\Backend\Block\Template | ||
{ | ||
/** | ||
* @var \Magento\Framework\Json\EncoderInterface | ||
*/ | ||
protected $jsonEncoder; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Json\EncoderInterface $jsonEncoder | ||
) { | ||
parent::__construct($context); | ||
$this->jsonEncoder = $jsonEncoder; | ||
} | ||
|
||
/** | ||
* Retrieve session checker data in JSON format | ||
* | ||
* @return string | ||
*/ | ||
public function getSessionCheckerJson() | ||
{ | ||
return $this->jsonEncoder->encode( | ||
[ | ||
'requestUrl' => $this->getUrl('security/session/check'), | ||
'redirectUrl' => $this->getUrl('adminhtml/') | ||
] | ||
); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
app/code/Magento/Security/Block/Adminhtml/Session/Activity.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,85 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Security\Block\Adminhtml\Session; | ||
|
||
/** | ||
* Block Session Activity | ||
*/ | ||
class Activity extends \Magento\Backend\Block\Template | ||
{ | ||
/** | ||
* @var \Magento\Security\Helper\SecurityConfig | ||
*/ | ||
protected $securityConfig; | ||
|
||
/** | ||
* @var \Magento\Security\Model\AdminSessionsManager | ||
*/ | ||
protected $sessionsManager; | ||
|
||
/** | ||
* @var \Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory | ||
*/ | ||
protected $sessionsInfoCollection; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Security\Helper\SecurityConfig $securityConfig | ||
* @param \Magento\Security\Model\AdminSessionsManager $sessionsManager | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Security\Helper\SecurityConfig $securityConfig, | ||
\Magento\Security\Model\AdminSessionsManager $sessionsManager | ||
) { | ||
parent::__construct($context); | ||
$this->securityConfig = $securityConfig; | ||
$this->sessionsManager = $sessionsManager; | ||
} | ||
|
||
/** | ||
* @return \Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection | ||
*/ | ||
public function getSessionInfoCollection() | ||
{ | ||
if (null === $this->sessionsInfoCollection) { | ||
$this->sessionsInfoCollection = $this->sessionsManager->getSessionsForCurrentUser(); | ||
} | ||
return $this->sessionsInfoCollection; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function areMultipleSessionsActive() | ||
{ | ||
return count($this->getSessionInfoCollection()) > 1; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRemoteIp() | ||
{ | ||
return $this->securityConfig->getRemoteIp(false); | ||
} | ||
|
||
/** | ||
* Retrieve formatting datatime | ||
* | ||
* @param string $time | ||
* @return string | ||
*/ | ||
public function formatDateTime($time) | ||
{ | ||
$time = new \DateTime($time); | ||
return $this->_localeDate->formatDateTime( | ||
$time, | ||
\IntlDateFormatter::MEDIUM, | ||
\IntlDateFormatter::MEDIUM | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/code/Magento/Security/Controller/Adminhtml/Session/Activity.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,22 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Security\Controller\Adminhtml\Session; | ||
|
||
/** | ||
* Admin session activity | ||
*/ | ||
class Activity extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function execute() | ||
{ | ||
$this->_view->loadLayout(); | ||
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Account Activity')); | ||
$this->_view->renderLayout(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
app/code/Magento/Security/Controller/Adminhtml/Session/Check.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,55 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Security\Controller\Adminhtml\Session; | ||
|
||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Security\Model\AdminSessionsManager; | ||
|
||
/** | ||
* Ajax Admin session checker | ||
*/ | ||
class Check extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* @var JsonFactory | ||
*/ | ||
protected $jsonFactory; | ||
|
||
/** | ||
* @var AdminSessionsManager | ||
*/ | ||
protected $sessionsManager; | ||
|
||
/** | ||
* Check constructor. | ||
* @param Context $context | ||
* @param JsonFactory $jsonFactory | ||
* @param AdminSessionsManager $sessionsManager | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
JsonFactory $jsonFactory, | ||
AdminSessionsManager $sessionsManager | ||
) { | ||
parent::__construct($context); | ||
$this->jsonFactory = $jsonFactory; | ||
$this->sessionsManager = $sessionsManager; | ||
} | ||
|
||
/** | ||
* @return \Magento\Framework\Controller\ResultInterface | ||
*/ | ||
public function execute() | ||
{ | ||
/** @var \Magento\Framework\Controller\Result\Json $resultJson */ | ||
return $this->jsonFactory->create()->setData( | ||
[ | ||
'isActive' => $this->sessionsManager->getCurrentSession()->isActive() | ||
] | ||
); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/code/Magento/Security/Controller/Adminhtml/Session/LogoutAll.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,49 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Security\Controller\Adminhtml\Session; | ||
|
||
use Magento\Backend\App\Action\Context; | ||
use Magento\Security\Model\AdminSessionsManager; | ||
|
||
/** | ||
* Admin session logout all | ||
*/ | ||
class LogoutAll extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* @var AdminSessionsManager | ||
*/ | ||
protected $sessionsManager; | ||
|
||
/** | ||
* Check constructor. | ||
* @param Context $context | ||
* @param AdminSessionsManager $sessionsManager | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
AdminSessionsManager $sessionsManager | ||
) { | ||
parent::__construct($context); | ||
$this->sessionsManager = $sessionsManager; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function execute() | ||
{ | ||
try { | ||
$this->sessionsManager->logoutOtherUserSessions(); | ||
$this->messageManager->addSuccess(__('All other open sessions for this account were terminated.')); | ||
} catch (\Magento\Framework\Exception\LocalizedException $e) { | ||
$this->messageManager->addError($e->getMessage()); | ||
} catch (\Exception $e) { | ||
$this->messageManager->addException($e, __("We couldn't logout because of an error.")); | ||
} | ||
$this->_redirect('*/*/activity'); | ||
} | ||
} |
Oops, something went wrong.