Skip to content

Commit e051f18

Browse files
author
Rafael Grigorian
committed
Fixed GH-5
1 parent 39a80b4 commit e051f18

File tree

10 files changed

+50
-47
lines changed

10 files changed

+50
-47
lines changed

src/app/code/community/JetRails/TwoFactor/Model/Adminhtml/Auth.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ protected function _construct () {
3535
* @return void
3636
*/
3737
public function registerAttempt ( $increment = true ) {
38-
3938
$data = Mage::helper ("twofactor/data");
4039
$state = Mage::getModel ("twofactor/state");
41-
4240
// Get the current timestamp and client IP address
4341
$timestamp = ( new Zend_Date () )->toString ("YYYY-MM-dd HH:mm:ss");
4442
$address = Mage::helper ("core/http")->getRemoteAddr ();

src/app/code/community/JetRails/TwoFactor/Model/Adminhtml/Observer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function preAdminHtml ( Varien_Event_Observer $observer ) {
9292
// Session is not authenticated, or is authenticated but not in verify state
9393
if ( $admin->getTwoFactorAllow () !== true || $userState != $state::VERIFY ) {
9494
// Allow state based routes to allow for state based pages
95-
if ( $page->isRouteAllowed ( $route, $userState ) ) return;
95+
if ( $page->isRouteAllowed ( "adminhtml/$controller/$action", $userState ) ) return;
9696
// If the state is not verify, then unset session flag
9797
if ( $userState != $state::VERIFY ) $admin->unsTwoFactorAllow ();
9898
// If there is a cookie and it is valid, then allow access to admin area

src/app/code/community/JetRails/TwoFactor/Model/Adminhtml/Page.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ class JetRails_TwoFactor_Model_Adminhtml_Page extends Mage_Core_Model_Abstract {
1717
* also includes all the controller routes that are defined for the manage and configure
1818
* controllers that only super admins have access to.
1919
*/
20-
const PAGE_SETUP_SCAN = "twofactor/setup/scan";
21-
const PAGE_SETUP_BACKUP = "twofactor/setup/backup";
22-
const PAGE_SETUP_RESET = "twofactor/setup/reset";
23-
const PAGE_SETUP_ENABLE = "twofactor/setup/enable";
24-
const PAGE_SETUP_DISABLE = "twofactor/setup/disable";
25-
const PAGE_LOGIN_BANNED = "twofactor/login/banned";
26-
const PAGE_LOGIN_VERIFY = "twofactor/login/verify";
27-
const PAGE_MANAGE_INDEX = "twofactor/manage/index";
28-
const PAGE_MANAGE_GRID = "twofactor/manage/grid";
29-
const PAGE_MANAGE_UNBAN = "twofactor/manage/unban";
30-
const PAGE_MANAGE_ENABLE = "twofactor/manage/enable";
31-
const PAGE_MANAGE_DISABLE = "twofactor/manage/disable";
32-
const PAGE_MANAGE_RESET = "twofactor/manage/reset";
33-
const PAGE_CONFIGURE_INDEX = "twofactor/configure/index";
34-
const PAGE_CONFIGURE_SAVE = "twofactor/configure/save";
20+
const PAGE_SETUP_SCAN = "adminhtml/twofactor_setup/scan";
21+
const PAGE_SETUP_BACKUP = "adminhtml/twofactor_setup/backup";
22+
const PAGE_SETUP_RESET = "adminhtml/twofactor_setup/reset";
23+
const PAGE_SETUP_ENABLE = "adminhtml/twofactor_setup/enable";
24+
const PAGE_SETUP_DISABLE = "adminhtml/twofactor_setup/disable";
25+
const PAGE_LOGIN_BANNED = "adminhtml/twofactor_login/banned";
26+
const PAGE_LOGIN_VERIFY = "adminhtml/twofactor_login/verify";
27+
const PAGE_MANAGE_INDEX = "adminhtml/twofactor_manage/index";
28+
const PAGE_MANAGE_GRID = "adminhtml/twofactor_manage/grid";
29+
const PAGE_MANAGE_UNBAN = "adminhtml/twofactor_manage/unban";
30+
const PAGE_MANAGE_ENABLE = "adminhtml/twofactor_manage/enable";
31+
const PAGE_MANAGE_DISABLE = "adminhtml/twofactor_manage/disable";
32+
const PAGE_MANAGE_RESET = "adminhtml/twofactor_manage/reset";
33+
const PAGE_CONFIGURE_INDEX = "adminhtml/twofactor_configure/index";
34+
const PAGE_CONFIGURE_SAVE = "adminhtml/twofactor_configure/save";
3535

3636
/**
3737
* This method takes in a controller route and an authorization state, which is defined in
@@ -82,9 +82,12 @@ public function getPageFromState ( $targetState ) {
8282
* @return boolean Is the route forbidden?
8383
*/
8484
public function isForbiddenRoutesAfterAuth ( $frontname, $controller ) {
85+
// Get current admin front name
86+
$adminFrontName = Mage::getConfig ()
87+
->getNode ("admin/routers/adminhtml/args/frontName");
8588
// Return if the controller is forbidden
86-
$allowed = array ( "setup", "login" );
87-
return $frontname === "twofactor" && in_array ( $controller, $allowed );
89+
$allowed = array ( "twofactor_setup", "twofactor_login" );
90+
return $frontname === "$adminFrontName" && in_array ( $controller, $allowed );
8891
}
8992

90-
}
93+
}

src/app/code/community/JetRails/TwoFactor/controllers/ConfigureController.php renamed to src/app/code/community/JetRails/TwoFactor/controllers/Twofactor/ConfigureController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @author Rafael Grigorian - JetRails®
1212
* @copyright JetRails®, all rights reserved
1313
*/
14-
class JetRails_TwoFactor_ConfigureController extends Mage_Adminhtml_Controller_Action {
14+
class JetRails_TwoFactor_Twofactor_ConfigureController extends Mage_Adminhtml_Controller_Action {
1515

1616
/**
1717
* This method simply asks Magento's ACL if the logged in user is allowed to see the
@@ -92,6 +92,8 @@ public function saveAction () {
9292
Mage::getSingleton ("admin/session")->addSuccess (
9393
Mage::helper ("twofactor")->__("Successfully saved settings")
9494
);
95+
// Invalidate config cache
96+
Mage::app ()->getCacheInstance ()->cleanType ("config");
9597
}
9698
else {
9799
// Attach an error message to the session
@@ -103,4 +105,4 @@ public function saveAction () {
103105
$this->getResponse ()->setRedirect ( $this->getUrl ( $page::PAGE_CONFIGURE_INDEX ) );
104106
}
105107

106-
}
108+
}

src/app/code/community/JetRails/TwoFactor/controllers/LoginController.php renamed to src/app/code/community/JetRails/TwoFactor/controllers/Twofactor/LoginController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @author Rafael Grigorian - JetRails®
1212
* @copyright JetRails®, all rights reserved
1313
*/
14-
class JetRails_TwoFactor_LoginController extends Mage_Adminhtml_Controller_Action {
14+
class JetRails_TwoFactor_Twofactor_LoginController extends Mage_Adminhtml_Controller_Action {
1515

1616
/**
1717
* This method asks the data helper to determine if the logged in admin user is allowed to
@@ -178,4 +178,4 @@ public function verifyAction () {
178178
$this->renderLayout ();
179179
}
180180

181-
}
181+
}

src/app/code/community/JetRails/TwoFactor/controllers/ManageController.php renamed to src/app/code/community/JetRails/TwoFactor/controllers/Twofactor/ManageController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @author Rafael Grigorian - JetRails®
1212
* @copyright JetRails®, all rights reserved
1313
*/
14-
class JetRails_TwoFactor_ManageController extends Mage_Adminhtml_Controller_Action {
14+
class JetRails_TwoFactor_Twofactor_ManageController extends Mage_Adminhtml_Controller_Action {
1515

1616
/**
1717
* This method simply asks Magento's ACL if the logged in user is allowed to see the
@@ -243,4 +243,4 @@ public function resetAction () {
243243
$this->_redirect ( $page::PAGE_MANAGE_INDEX );
244244
}
245245

246-
}
246+
}

src/app/code/community/JetRails/TwoFactor/controllers/SetupController.php renamed to src/app/code/community/JetRails/TwoFactor/controllers/Twofactor/SetupController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @author Rafael Grigorian - JetRails®
1111
* @copyright JetRails®, all rights reserved
1212
*/
13-
class JetRails_TwoFactor_SetupController extends Mage_Adminhtml_Controller_Action {
13+
class JetRails_TwoFactor_Twofactor_SetupController extends Mage_Adminhtml_Controller_Action {
1414

1515
/**
1616
* This method asks the data helper to determine if the logged in admin user is allowed to
@@ -97,4 +97,4 @@ public function backupAction () {
9797
$this->renderLayout ();
9898
}
9999

100-
}
100+
}

src/app/code/community/JetRails/TwoFactor/etc/adminhtml.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@
4141
<configure translate="title" module="twofactor" >
4242
<title>Configure 2FA Settings</title>
4343
<sort_order>10</sort_order>
44-
<action>twofactor/configure/index</action>
44+
<action>adminhtml/twofactor_configure/index</action>
4545
</configure>
4646
<manage translate="title" module="twofactor" >
4747
<title>Manage 2FA Accounts</title>
4848
<sort_order>20</sort_order>
49-
<action>twofactor/manage/index</action>
49+
<action>adminhtml/twofactor_manage/index</action>
5050
</manage>
5151
</children>
5252
</twofactor>
5353
</children>
5454
</jetrails>
5555
</menu>
56-
</config>
56+
</config>

src/app/code/community/JetRails/TwoFactor/etc/config.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
</modules>
99
<admin>
1010
<routers>
11-
<jetrails_twofactor>
12-
<use>admin</use>
11+
<adminhtml>
1312
<args>
14-
<module>JetRails_TwoFactor</module>
15-
<frontName>twofactor</frontName>
13+
<modules>
14+
<JetRails_TwoFactor before="Mage_Adminhtml" >JetRails_TwoFactor</JetRails_TwoFactor>
15+
</modules>
1616
</args>
17-
</jetrails_twofactor>
17+
</adminhtml>
1818
</routers>
1919
</admin>
2020
<global>
@@ -105,4 +105,4 @@
105105
</general>
106106
</twofactor>
107107
</default>
108-
</config>
108+
</config>

src/app/design/adminhtml/base/default/layout/twofactor.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22

33
<layout>
4-
<jetrails_twofactor_login_verify>
4+
<adminhtml_twofactor_login_verify>
55
<block
66
name="root"
77
type="core/template"
@@ -19,8 +19,8 @@
1919
type="twofactor/template_verify"
2020
template="twofactor/verify.phtml" />
2121
</block>
22-
</jetrails_twofactor_login_verify>
23-
<jetrails_twofactor_login_banned>
22+
</adminhtml_twofactor_login_verify>
23+
<adminhtml_twofactor_login_banned>
2424
<block
2525
name="root"
2626
type="core/template"
@@ -34,8 +34,8 @@
3434
type="twofactor/template_banned"
3535
template="twofactor/banned.phtml" />
3636
</block>
37-
</jetrails_twofactor_login_banned>
38-
<jetrails_twofactor_setup_scan>
37+
</adminhtml_twofactor_login_banned>
38+
<adminhtml_twofactor_setup_scan>
3939
<block
4040
name="root"
4141
type="core/template"
@@ -53,8 +53,8 @@
5353
type="twofactor/template_scan"
5454
template="twofactor/scan.phtml" />
5555
</block>
56-
</jetrails_twofactor_setup_scan>
57-
<jetrails_twofactor_setup_backup>
56+
</adminhtml_twofactor_setup_scan>
57+
<adminhtml_twofactor_setup_backup>
5858
<block
5959
name="root"
6060
type="core/template"
@@ -68,5 +68,5 @@
6868
type="twofactor/template_backup"
6969
template="twofactor/backup.phtml" />
7070
</block>
71-
</jetrails_twofactor_setup_backup>
72-
</layout>
71+
</adminhtml_twofactor_setup_backup>
72+
</layout>

0 commit comments

Comments
 (0)