Skip to content

Commit 01141f4

Browse files
author
He, Joan(johe)
committed
Merge pull request #342 from magento-extensibility/MAGETWO-38635-prs
[Extensibility] Magetwo 38635 prs
2 parents 03ec736 + 0bc11e1 commit 01141f4

File tree

82 files changed

+6803
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+6803
-21
lines changed

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,16 @@
414414
</group>
415415
<group id="security" translate="label" type="text" sortOrder="35" showInDefault="1" showInWebsite="0" showInStore="0">
416416
<label>Security</label>
417-
<field id="use_form_key" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
417+
<field id="use_form_key" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
418418
<label>Add Secret Key to URLs</label>
419419
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
420420
<backend_model>Magento\Config\Model\Config\Backend\Admin\Usesecretkey</backend_model>
421421
</field>
422-
<field id="use_case_sensitive_login" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
422+
<field id="use_case_sensitive_login" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
423423
<label>Login is Case Sensitive</label>
424424
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
425425
</field>
426-
<field id="session_lifetime" translate="label comment" sortOrder="3" showInDefault="1" showInWebsite="0" showInStore="0">
426+
<field id="session_lifetime" translate="label comment" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
427427
<label>Admin Session Lifetime (seconds)</label>
428428
<comment>Values less than 60 are ignored.</comment>
429429
<validate>validate-digits</validate>

app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
use Magento\Framework\App\Action\Context;
1313
use Magento\Framework\Escaper;
1414
use Magento\Framework\Exception\NoSuchEntityException;
15+
use Magento\Framework\Exception\SecurityViolationException;
1516

17+
/**
18+
* ForgotPasswordPost controller
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20+
*/
1621
class ForgotPasswordPost extends \Magento\Customer\Controller\AbstractAccount
1722
{
1823
/** @var AccountManagementInterface */
@@ -66,8 +71,11 @@ public function execute()
6671
$email,
6772
AccountManagement::EMAIL_RESET
6873
);
69-
} catch (NoSuchEntityException $e) {
74+
} catch (NoSuchEntityException $exception) {
7075
// Do nothing, we don't want anyone to use this action to determine which email accounts are registered.
76+
} catch (SecurityViolationException $exception) {
77+
$this->messageManager->addErrorMessage($exception->getMessage());
78+
return $resultRedirect->setPath('*/*/forgotpassword');
7179
} catch (\Exception $exception) {
7280
$this->messageManager->addExceptionMessage(
7381
$exception,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Security\Block\Adminhtml\Js;
7+
8+
/**
9+
* Block Session Checker
10+
*/
11+
class Checker extends \Magento\Backend\Block\Template
12+
{
13+
/**
14+
* @var \Magento\Framework\Json\EncoderInterface
15+
*/
16+
protected $jsonEncoder;
17+
18+
/**
19+
* @param \Magento\Backend\Block\Template\Context $context
20+
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
21+
*/
22+
public function __construct(
23+
\Magento\Backend\Block\Template\Context $context,
24+
\Magento\Framework\Json\EncoderInterface $jsonEncoder
25+
) {
26+
parent::__construct($context);
27+
$this->jsonEncoder = $jsonEncoder;
28+
}
29+
30+
/**
31+
* Retrieve session checker data in JSON format
32+
*
33+
* @return string
34+
*/
35+
public function getSessionCheckerJson()
36+
{
37+
return $this->jsonEncoder->encode(
38+
[
39+
'requestUrl' => $this->getUrl('security/session/check'),
40+
'redirectUrl' => $this->getUrl('adminhtml/')
41+
]
42+
);
43+
}
44+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Security\Block\Adminhtml\Session;
7+
8+
/**
9+
* Block Session Activity
10+
*/
11+
class Activity extends \Magento\Backend\Block\Template
12+
{
13+
/**
14+
* @var \Magento\Security\Helper\SecurityConfig
15+
*/
16+
protected $securityConfig;
17+
18+
/**
19+
* @var \Magento\Security\Model\AdminSessionsManager
20+
*/
21+
protected $sessionsManager;
22+
23+
/**
24+
* @var \Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory
25+
*/
26+
protected $sessionsInfoCollection;
27+
28+
/**
29+
* @param \Magento\Backend\Block\Template\Context $context
30+
* @param \Magento\Security\Helper\SecurityConfig $securityConfig
31+
* @param \Magento\Security\Model\AdminSessionsManager $sessionsManager
32+
*/
33+
public function __construct(
34+
\Magento\Backend\Block\Template\Context $context,
35+
\Magento\Security\Helper\SecurityConfig $securityConfig,
36+
\Magento\Security\Model\AdminSessionsManager $sessionsManager
37+
) {
38+
parent::__construct($context);
39+
$this->securityConfig = $securityConfig;
40+
$this->sessionsManager = $sessionsManager;
41+
}
42+
43+
/**
44+
* @return \Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection
45+
*/
46+
public function getSessionInfoCollection()
47+
{
48+
if (null === $this->sessionsInfoCollection) {
49+
$this->sessionsInfoCollection = $this->sessionsManager->getSessionsForCurrentUser();
50+
}
51+
return $this->sessionsInfoCollection;
52+
}
53+
54+
/**
55+
* @return bool
56+
*/
57+
public function areMultipleSessionsActive()
58+
{
59+
return count($this->getSessionInfoCollection()) > 1;
60+
}
61+
62+
/**
63+
* @return string
64+
*/
65+
public function getRemoteIp()
66+
{
67+
return $this->securityConfig->getRemoteIp(false);
68+
}
69+
70+
/**
71+
* Retrieve formatting datatime
72+
*
73+
* @param string $time
74+
* @return string
75+
*/
76+
public function formatDateTime($time)
77+
{
78+
$time = new \DateTime($time);
79+
return $this->_localeDate->formatDateTime(
80+
$time,
81+
\IntlDateFormatter::MEDIUM,
82+
\IntlDateFormatter::MEDIUM
83+
);
84+
}
85+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Security\Controller\Adminhtml\Session;
7+
8+
/**
9+
* Admin session activity
10+
*/
11+
class Activity extends \Magento\Backend\App\Action
12+
{
13+
/**
14+
* @return void
15+
*/
16+
public function execute()
17+
{
18+
$this->_view->loadLayout();
19+
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Account Activity'));
20+
$this->_view->renderLayout();
21+
}
22+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Security\Controller\Adminhtml\Session;
7+
8+
use Magento\Backend\App\Action\Context;
9+
use Magento\Framework\Controller\Result\JsonFactory;
10+
use Magento\Security\Model\AdminSessionsManager;
11+
12+
/**
13+
* Ajax Admin session checker
14+
*/
15+
class Check extends \Magento\Backend\App\Action
16+
{
17+
/**
18+
* @var JsonFactory
19+
*/
20+
protected $jsonFactory;
21+
22+
/**
23+
* @var AdminSessionsManager
24+
*/
25+
protected $sessionsManager;
26+
27+
/**
28+
* Check constructor.
29+
* @param Context $context
30+
* @param JsonFactory $jsonFactory
31+
* @param AdminSessionsManager $sessionsManager
32+
*/
33+
public function __construct(
34+
Context $context,
35+
JsonFactory $jsonFactory,
36+
AdminSessionsManager $sessionsManager
37+
) {
38+
parent::__construct($context);
39+
$this->jsonFactory = $jsonFactory;
40+
$this->sessionsManager = $sessionsManager;
41+
}
42+
43+
/**
44+
* @return \Magento\Framework\Controller\ResultInterface
45+
*/
46+
public function execute()
47+
{
48+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
49+
return $this->jsonFactory->create()->setData(
50+
[
51+
'isActive' => $this->sessionsManager->getCurrentSession()->isActive()
52+
]
53+
);
54+
}
55+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Security\Controller\Adminhtml\Session;
7+
8+
use Magento\Backend\App\Action\Context;
9+
use Magento\Security\Model\AdminSessionsManager;
10+
11+
/**
12+
* Admin session logout all
13+
*/
14+
class LogoutAll extends \Magento\Backend\App\Action
15+
{
16+
/**
17+
* @var AdminSessionsManager
18+
*/
19+
protected $sessionsManager;
20+
21+
/**
22+
* Check constructor.
23+
* @param Context $context
24+
* @param AdminSessionsManager $sessionsManager
25+
*/
26+
public function __construct(
27+
Context $context,
28+
AdminSessionsManager $sessionsManager
29+
) {
30+
parent::__construct($context);
31+
$this->sessionsManager = $sessionsManager;
32+
}
33+
34+
/**
35+
* @return void
36+
*/
37+
public function execute()
38+
{
39+
try {
40+
$this->sessionsManager->logoutOtherUserSessions();
41+
$this->messageManager->addSuccess(__('All other open sessions for this account were terminated.'));
42+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
43+
$this->messageManager->addError($e->getMessage());
44+
} catch (\Exception $e) {
45+
$this->messageManager->addException($e, __("We couldn't logout because of an error."));
46+
}
47+
$this->_redirect('*/*/activity');
48+
}
49+
}

0 commit comments

Comments
 (0)