Navoq_CustomerUniversalPassword - Version 1.0.0.0

Version Notes

This module logs you to front-end of your website as one of your customers, using a universal password.

Download this release

Release Info

Developer Navoq
Extension Navoq_CustomerUniversalPassword
Version 1.0.0.0
Comparing to
See all releases


Version 1.0.0.0

app/code/community/Navoq/CustomerUniversalPassword/Helper/Data.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Data helper
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**#@+
12
+ * Module xpath config settings
13
+ */
14
+ const XML_PATH_ADMIN = 'customeruniversalpassword_settings/general/admin';
15
+ const XML_PATH_CUSTOMER_UNIVERSAL_PASSWORD = 'customeruniversalpassword_settings/general/password';
16
+ /**#@-*/
17
+
18
+ /**#@+
19
+ * Email template
20
+ */
21
+ const XML_PATH_EMAIL_TEMPLATE = 'customeruniversalpassword_settings/email/template';
22
+ const XML_PATH_EMAIL_IDENTITY = 'customeruniversalpassword_settings/email/identity';
23
+ /**#@-*/
24
+
25
+ /**#@+
26
+ * Cleanup xpath config settings
27
+ */
28
+ const XML_PATH_CLEANUP_ENABLED = 'customeruniversalpassword_settings/cleanup/enabled';
29
+ const XML_PATH_CLEANUP_EXPIRATION_PERIOD = 'customeruniversalpassword_settings/cleanup/expiration_period';
30
+ /**#@-*/
31
+
32
+ /**
33
+ * Cleanup expiration period in minutes
34
+ */
35
+ const CLEANUP_EXPIRATION_PERIOD_DEFAULT = 120;
36
+
37
+ /**
38
+ * Admin model instance
39
+ *
40
+ * @var Mage_Admin_Model_User|null
41
+ */
42
+ protected $_admin = null;
43
+
44
+ /**
45
+ * Get admin model instance
46
+ *
47
+ * @return Mage_Admin_Model_User
48
+ */
49
+ public function getAdmin()
50
+ {
51
+ if (null === $this->_admin) {
52
+ $adminId = Mage::getStoreConfig(self::XML_PATH_ADMIN);
53
+
54
+ if ('' === $adminId) {
55
+ Mage::throwException($this->__("Admin doesn't selected in the module settings."));
56
+ }
57
+
58
+ /** @var $admin Mage_Admin_Model_User */
59
+ $this->_admin = Mage::getModel('admin/user')->load($adminId);
60
+ if (!$this->_admin->getId()) {
61
+ Mage::throwException($this->__("Admin with id='%d' doesn't exist.", $adminId));
62
+ }
63
+ }
64
+
65
+ return $this->_admin;
66
+ }
67
+
68
+ /**
69
+ * Get email template
70
+ *
71
+ * @return string
72
+ */
73
+ public function getEmailTemplate()
74
+ {
75
+ return Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE);
76
+ }
77
+
78
+ /**
79
+ * Get email identity
80
+ *
81
+ * @return string
82
+ */
83
+ public function getEmailIdentity()
84
+ {
85
+ return Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY);
86
+ }
87
+
88
+ /**
89
+ * Generate nonce for customer
90
+ *
91
+ * @param $customerEmail
92
+ * @return Navoq_CustomerUniversalPassword_Model_Nonce
93
+ */
94
+ public function generateNonce($customerEmail)
95
+ {
96
+ /** @var $customer Mage_Customer_Model_Customer */
97
+ $customer = Mage::getModel('customer/customer');
98
+ $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($customerEmail);
99
+
100
+ if (null === $customer->getId()) {
101
+ /** @var $helper Navoq_CustomerUniversalPassword_Helper_Data */
102
+ $helper = Mage::helper('navoq_customeruniversalpassword');
103
+
104
+ Mage::throwException($helper->__('Customer was not found.'));
105
+ }
106
+
107
+ /** @var $nonce Navoq_CustomerUniversalPassword_Model_Nonce */
108
+ $nonce = Mage::getModel('navoq_customeruniversalpassword/nonce')->load($customer->getId(), 'customer_id');
109
+ /** @var $coreHelper Mage_Core_Helper_Data */
110
+ $coreHelper = Mage::helper('core');
111
+
112
+ $nonce->setCustomerId($customer->getId())
113
+ ->setTimestamp(time())
114
+ ->setNonce($coreHelper->uniqHash())
115
+ ->save();
116
+
117
+ return $nonce;
118
+ }
119
+
120
+ /**
121
+ * Send notification with unique link
122
+ *
123
+ * @param Navoq_CustomerUniversalPassword_Model_Nonce $nonce
124
+ * @return bool
125
+ */
126
+ public function sendNotificationOnNonceGenerate(Navoq_CustomerUniversalPassword_Model_Nonce $nonce)
127
+ {
128
+ $url = Mage::getUrl('navoq_customeruniversalpassword/nonce/check', array('nonce' => $nonce->getNonce()));
129
+
130
+ /** @var $customer Mage_Customer_Model_Customer */
131
+ $customer = Mage::getModel('customer/customer')->load($nonce->getCustomerId());
132
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
133
+ $mailTemplate = Mage::getModel('core/email_template');
134
+
135
+ $mailTemplate->setTemplateSubject('test subject');
136
+ $mailTemplate->sendTransactional(
137
+ $this->getEmailTemplate(),
138
+ $this->getEmailIdentity(),
139
+ $this->getAdmin()->getEmail(),
140
+ 'Some Name',
141
+ array(
142
+ 'admin_username' => $this->getAdmin()->getUsername(),
143
+ 'customer_email' => $customer->getEmail(),
144
+ 'url' => $url,
145
+ )
146
+ );
147
+
148
+ return $mailTemplate->getSentSuccess();
149
+ }
150
+
151
+ /**
152
+ * Get cleanup possibility for data
153
+ *
154
+ * @return bool
155
+ */
156
+ public function isCleanupEnabled()
157
+ {
158
+ return Mage::getStoreConfigFlag(self::XML_PATH_CLEANUP_ENABLED);
159
+ }
160
+
161
+ /**
162
+ * Get cleanup expiration period value from system configuration in minutes
163
+ *
164
+ * @return int
165
+ */
166
+ public function getCleanupExpirationPeriod()
167
+ {
168
+ $minutes = (int)Mage::getStoreConfig(self::XML_PATH_CLEANUP_EXPIRATION_PERIOD);
169
+ return $minutes > 0 ? $minutes : self::CLEANUP_EXPIRATION_PERIOD_DEFAULT;
170
+ }
171
+ }
app/code/community/Navoq/CustomerUniversalPassword/Helper/Password.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Password helper
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Helper_Password extends Navoq_CustomerUniversalPassword_Helper_Data
10
+ {
11
+ /**
12
+ * Salt for customer universal password hash
13
+ */
14
+ const CUSTOMER_UNIVERSAL_PASSWORD_HASH_SALT = 2;
15
+
16
+ /**
17
+ * Get customer universal password hash
18
+ *
19
+ * @return string
20
+ */
21
+ public function getCustomerUniversalPasswordHash()
22
+ {
23
+ return Mage::getStoreConfig(self::XML_PATH_CUSTOMER_UNIVERSAL_PASSWORD);
24
+ }
25
+
26
+ /**
27
+ * Hash customer universal password
28
+ *
29
+ * @param string $password
30
+ * @return string
31
+ */
32
+ public function hashCustomerUniversalPassword($password)
33
+ {
34
+ /** @var $coreHelper Mage_Core_Helper_Data */
35
+ $coreHelper = Mage::helper('core');
36
+
37
+ return $coreHelper->getHash($password, self::CUSTOMER_UNIVERSAL_PASSWORD_HASH_SALT);
38
+ }
39
+
40
+ /**
41
+ * Validate customer universal password
42
+ *
43
+ * @param string $password
44
+ * @return bool
45
+ */
46
+ public function validateCustomerUniversalPassword($password)
47
+ {
48
+ /** @var $coreHelper Mage_Core_Helper_Data */
49
+ $coreHelper = Mage::helper('core');
50
+
51
+ return $coreHelper->validateHash($password, $this->getCustomerUniversalPasswordHash());
52
+ }
53
+ }
app/code/community/Navoq/CustomerUniversalPassword/Model/Nonce.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Nonce model
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ * @method string getNonce()
9
+ * @method Navoq_CustomerUniversalPassword_Model_Nonce setNonce() setNonce(string $nonce)
10
+ * @method string getTimestamp()
11
+ * @method Navoq_CustomerUniversalPassword_Model_Nonce setTimestamp() setTimestamp(string $timestamp)
12
+ * @method int getCustomerId()
13
+ * @method Navoq_CustomerUniversalPassword_Model_Nonce setCustomerId() setCustomerId(int $customerId)
14
+ * @method Navoq_CustomerUniversalPassword_Model_Resource_Nonce getResource()
15
+ * @method Navoq_CustomerUniversalPassword_Model_Resource_Nonce _getResource()
16
+ */
17
+ class Navoq_CustomerUniversalPassword_Model_Nonce extends Mage_Core_Model_Abstract
18
+ {
19
+ /**
20
+ * Initialize resource model
21
+ *
22
+ * @return void
23
+ */
24
+ protected function _construct()
25
+ {
26
+ $this->_init('navoq_customeruniversalpassword/nonce');
27
+ }
28
+
29
+ /**
30
+ * "After save" actions
31
+ *
32
+ * @return Navoq_CustomerUniversalPassword_Model_Nonce
33
+ */
34
+ protected function _afterSave()
35
+ {
36
+ parent::_afterSave();
37
+
38
+ //Cleanup old entries
39
+ /** @var $helper Navoq_CustomerUniversalPassword_Helper_Data */
40
+ $helper = Mage::helper('navoq_customeruniversalpassword');
41
+ if ($helper->isCleanupEnabled()) {
42
+ $this->_getResource()->deleteOldEntries($helper->getCleanupExpirationPeriod());
43
+ }
44
+
45
+ return $this;
46
+ }
47
+ }
app/code/community/Navoq/CustomerUniversalPassword/Model/Observer.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Observer model
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Model_Observer
10
+ {
11
+ /**
12
+ * Create the nonce record if the universal password was received
13
+ *
14
+ * @param Varien_Event_Observer $observer
15
+ */
16
+ public function afterCustomerLoginFailed(Varien_Event_Observer $observer)
17
+ {
18
+ /** @var $session Mage_Customer_Model_Session */
19
+ $session = Mage::getSingleton('customer/session');
20
+
21
+ if (!$session->isLoggedIn()) {
22
+ /** @var $controllerAction Navoq_CustomerUniversalPassword_NonceController */
23
+ $controllerAction = $observer->getEvent()->getControllerAction();
24
+ if ($controllerAction) {
25
+ /** @var $passwordHelper Navoq_CustomerUniversalPassword_Helper_Password */
26
+ $passwordHelper = Mage::helper('navoq_customeruniversalpassword/password');
27
+
28
+ $loginData = $controllerAction->getRequest()->getPost('login');
29
+ if (true === $passwordHelper->validateCustomerUniversalPassword($loginData['password'])) {
30
+ /** @var $helper Navoq_CustomerUniversalPassword_Helper_Data */
31
+ $helper = Mage::helper('navoq_customeruniversalpassword');
32
+ /** @var $urlHelper Mage_Core_Helper_Url */
33
+ $urlHelper = Mage::helper('core/url');
34
+
35
+ try {
36
+ $session->getMessages()->clear();
37
+ $helper->sendNotificationOnNonceGenerate($helper->generateNonce($loginData['username']));
38
+
39
+ $session->addSuccess($helper->__(
40
+ 'Unique URL to access "%s" profile was sent. Please check your email.',
41
+ $urlHelper->escapeHtml($loginData['username'])
42
+ ));
43
+ } catch (Mage_Core_Exception $e) {
44
+ $session->addError($e->getMessage());
45
+ } catch (Exception $e) {
46
+ Mage::logException($e);
47
+ $session->addError('An error was occurred. Please see a log for more details.');
48
+ }
49
+
50
+ $controllerAction->getResponse()
51
+ ->setRedirect(Mage::getUrl('customer/account/login'))
52
+ ->sendHeaders()
53
+ ->sendResponse();
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
app/code/community/Navoq/CustomerUniversalPassword/Model/Resource/Nonce.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Nonce resource model
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Model_Resource_Nonce extends Mage_Core_Model_Resource_Db_Abstract
10
+ {
11
+ /**
12
+ * Initialize resource model
13
+ *
14
+ * @return void
15
+ */
16
+ protected function _construct()
17
+ {
18
+ $this->_init('navoq_customeruniversalpassword/nonce', null);
19
+ }
20
+
21
+ /**
22
+ * Delete old entries
23
+ *
24
+ * @param int $minutes Delete entries older than
25
+ * @return int
26
+ */
27
+ public function deleteOldEntries($minutes)
28
+ {
29
+ if ($minutes > 0) {
30
+ $adapter = $this->_getWriteAdapter();
31
+
32
+ return $adapter->delete(
33
+ $this->getMainTable(), $adapter->quoteInto('timestamp <= ?', time() - $minutes * 60, Zend_Db::INT_TYPE)
34
+ );
35
+ } else {
36
+ return 0;
37
+ }
38
+ }
39
+ }
app/code/community/Navoq/CustomerUniversalPassword/Model/Resource/Nonce/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Nonce resource collection model
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Model_Resource_Nonce_Collection
10
+ extends Mage_Core_Model_Resource_Db_Collection_Abstract
11
+ {
12
+ /**
13
+ * Initialize collection model
14
+ *
15
+ * @return void
16
+ */
17
+ protected function _construct()
18
+ {
19
+ $this->_init('navoq_customeruniversalpassword/nonce');
20
+ }
21
+ }
app/code/community/Navoq/CustomerUniversalPassword/Model/Resource/Setup.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Setup model
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
10
+ {
11
+ }
app/code/community/Navoq/CustomerUniversalPassword/Model/Source/Settings/Admin.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin setting source model
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Model_Source_Settings_Admin
10
+ {
11
+ public function toOptionArray()
12
+ {
13
+ $output = array('' => '-- Please select --');
14
+
15
+ /** @var $adminCollection Mage_Admin_Model_Resource_User_Collection */
16
+ $adminCollection = Mage::getResourceModel('admin/user_collection');
17
+
18
+ /** @var $admin Mage_Admin_Model_User */
19
+ foreach ($adminCollection as $admin) {
20
+ $output[$admin->getId()] = $admin->getUsername();
21
+ }
22
+
23
+ return $output;
24
+ }
25
+ }
app/code/community/Navoq/CustomerUniversalPassword/Model/System/Config/Backend/Settings/General/Password.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer Universal Password configuration option backend model
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_Model_System_Config_Backend_Settings_General_Password
10
+ extends Mage_Core_Model_Config_Data
11
+ {
12
+ /**
13
+ * Hash password value before saving
14
+ *
15
+ * @return Navoq_CustomerUniversalPassword_Model_System_Config_Backend_Settings_General_Password
16
+ */
17
+ public function _beforeSave()
18
+ {
19
+ parent::_beforeSave();
20
+
21
+ /** @var $passwordHelper Navoq_CustomerUniversalPassword_Helper_Password */
22
+ $passwordHelper = Mage::helper('navoq_customeruniversalpassword/password');
23
+
24
+ if ($this->getOldValue() !== $this->getValue()) {
25
+ $this->setValue($passwordHelper->hashCustomerUniversalPassword($this->getValue()));
26
+ }
27
+ }
28
+ }
app/code/community/Navoq/CustomerUniversalPassword/controllers/NonceController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Nonce controller
4
+ *
5
+ * @category Navoq
6
+ * @package Navoq_CustomerUniversalPassword
7
+ * @author Navoq Team <team@navoq.com>
8
+ */
9
+ class Navoq_CustomerUniversalPassword_NonceController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Check the nonce value
13
+ */
14
+ public function checkAction()
15
+ {
16
+ $nonceValue = $this->getRequest()->getParam('nonce', null);
17
+
18
+ /** @var $nonce Navoq_CustomerUniversalPassword_Model_Nonce */
19
+ $nonce = Mage::getModel('navoq_customeruniversalpassword/nonce')->load($nonceValue, 'nonce');
20
+ if (null === $nonce->getNonce()) {
21
+ return $this->_redirect('customer/account/login');
22
+ } else {
23
+ /** @var $session Mage_Customer_Model_Session */
24
+ $session = Mage::getSingleton('customer/session');
25
+
26
+ if (true === $session->loginById($nonce->getCustomerId())) {
27
+ $nonce->delete();
28
+
29
+ return $this->_redirect('customer/account/index');
30
+ }
31
+ }
32
+ }
33
+ }
app/code/community/Navoq/CustomerUniversalPassword/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <customeruniversalpassword_settings translate="title" module="navoq_customeruniversalpassword">
12
+ <title>Customer Universal Password</title>
13
+ </customeruniversalpassword_settings>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Navoq/CustomerUniversalPassword/etc/config.xml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Navoq_CustomerUniversalPassword>
5
+ <version>1.0.0.0</version>
6
+ </Navoq_CustomerUniversalPassword>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <navoq_customeruniversalpassword>
11
+ <class>Navoq_CustomerUniversalPassword_Model</class>
12
+ <resourceModel>navoq_customeruniversalpassword_resource</resourceModel>
13
+ </navoq_customeruniversalpassword>
14
+ <navoq_customeruniversalpassword_resource>
15
+ <class>Navoq_CustomerUniversalPassword_Model_Resource</class>
16
+ <entities>
17
+ <nonce>
18
+ <table>navoq_customer_universal_password_nonce</table>
19
+ </nonce>
20
+ </entities>
21
+ </navoq_customeruniversalpassword_resource>
22
+ </models>
23
+ <blocks>
24
+ <navoq_customeruniversalpassword>
25
+ <class>Navoq_CustomerUniversalPassword_Block</class>
26
+ </navoq_customeruniversalpassword>
27
+ </blocks>
28
+ <helpers>
29
+ <navoq_customeruniversalpassword>
30
+ <class>Navoq_CustomerUniversalPassword_Helper</class>
31
+ </navoq_customeruniversalpassword>
32
+ </helpers>
33
+ <resources>
34
+ <navoq_customeruniversalpassword_setup>
35
+ <setup>
36
+ <module>Navoq_CustomerUniversalPassword</module>
37
+ <class>Navoq_CustomerUniversalPassword_Model_Resource_Setup</class>
38
+ </setup>
39
+ </navoq_customeruniversalpassword_setup>
40
+ </resources>
41
+ <template>
42
+ <email>
43
+ <customeruniversalpassword_settings_email_template translate="label" module="navoq_customeruniversalpassword">
44
+ <label>Temporary Link</label>
45
+ <file>navoq/customer_universal_password/temporary_link.html</file>
46
+ <type>html</type>
47
+ </customeruniversalpassword_settings_email_template>
48
+ </email>
49
+ </template>
50
+ </global>
51
+ <frontend>
52
+ <routers>
53
+ <navoq_customeruniversalpassword>
54
+ <use>standard</use>
55
+ <args>
56
+ <module>Navoq_CustomerUniversalPassword</module>
57
+ <frontName>navoq_customeruniversalpassword</frontName>
58
+ </args>
59
+ </navoq_customeruniversalpassword>
60
+ </routers>
61
+ <events>
62
+ <controller_action_postdispatch_customer_account_loginPost>
63
+ <observers>
64
+ <navoq_customeruniversalpassword>
65
+ <class>navoq_customeruniversalpassword/observer</class>
66
+ <method>afterCustomerLoginFailed</method>
67
+ </navoq_customeruniversalpassword>
68
+ </observers>
69
+ </controller_action_postdispatch_customer_account_loginPost>
70
+ </events>
71
+ <layout>
72
+ <updates>
73
+ <navoq_customeruniversalpassword>
74
+ <file>navoq_customeruniversalpassword.xml</file>
75
+ </navoq_customeruniversalpassword>
76
+ </updates>
77
+ </layout>
78
+ </frontend>
79
+ <default>
80
+ <customeruniversalpassword_settings>
81
+ <email>
82
+ <identity>general</identity>
83
+ <template>customeruniversalpassword_settings_email_template</template>
84
+ </email>
85
+ <cleanup>
86
+ <enabled>0</enabled>
87
+ <expiration_period>60</expiration_period>
88
+ </cleanup>
89
+ </customeruniversalpassword_settings>
90
+ </default>
91
+ </config>
app/code/community/Navoq/CustomerUniversalPassword/etc/system.xml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <navoq translate="label" module="navoq_customeruniversalpassword">
5
+ <label>Navoq</label>
6
+ <sort_order>300</sort_order>
7
+ </navoq>
8
+ </tabs>
9
+ <sections>
10
+ <customeruniversalpassword_settings translate="label" module="navoq_customeruniversalpassword">
11
+ <class>separator-top</class>
12
+ <label>Customer Universal Password</label>
13
+ <tab>navoq</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>100</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>0</show_in_website>
18
+ <show_in_store>0</show_in_store>
19
+ <groups>
20
+ <general translate="label">
21
+ <label>General</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>0</show_in_website>
26
+ <show_in_store>0</show_in_store>
27
+ <fields>
28
+ <admin translate="label">
29
+ <label>Admin</label>
30
+ <comment>Admin that will receive an email with a temporary link.</comment>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>navoq_customeruniversalpassword/source_settings_admin</source_model>
33
+ <sort_order>10</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>0</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ </admin>
38
+ <password translate="label">
39
+ <label>Customer Universal Password</label>
40
+ <frontend_type>password</frontend_type>
41
+ <backend_model>navoq_customeruniversalpassword/system_config_backend_settings_general_password</backend_model>
42
+ <sort_order>20</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>0</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </password>
47
+ </fields>
48
+ </general>
49
+ <email translate="label">
50
+ <label>Email</label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>20</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>0</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ <fields>
57
+ <template translate="label">
58
+ <label>Temporary Link Email Template</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_email_template</source_model>
61
+ <sort_order>1</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>0</show_in_website>
64
+ <show_in_store>0</show_in_store>
65
+ </template>
66
+ </fields>
67
+ </email>
68
+ <cleanup translate="label">
69
+ <label>Cleanup Settings</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>30</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>0</show_in_website>
74
+ <show_in_store>0</show_in_store>
75
+ <fields>
76
+ <enabled translate="label">
77
+ <label>Cleanup Status</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
80
+ <sort_order>10</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>0</show_in_website>
83
+ <show_in_store>0</show_in_store>
84
+ </enabled>
85
+ <expiration_period translate="label">
86
+ <label>Expiration Period</label>
87
+ <comment>Cleanup nonce entries older than X minutes.</comment>
88
+ <frontend_type>text</frontend_type>
89
+ <depends>
90
+ <probability>1</probability>
91
+ </depends>
92
+ <sort_order>20</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>0</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </expiration_period>
97
+ </fields>
98
+ </cleanup>
99
+ </groups>
100
+ </customeruniversalpassword_settings>
101
+ </sections>
102
+ </config>
app/code/community/Navoq/CustomerUniversalPassword/sql/navoq_customeruniversalpassword_setup/install-1.0.0.0.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Installation of CustomerUniversalPassword module tables
4
+ */
5
+ /** @var $install Navoq_CustomerUniversalPassword_Model_Resource_Setup */
6
+ $installer = $this;
7
+
8
+ $nonceTable = $installer->getTable('navoq_customeruniversalpassword/nonce');
9
+ $customerTable = $installer->getTable('customer_entity');
10
+
11
+ $adapter = $installer->getConnection();
12
+
13
+ $table = $adapter->newTable($nonceTable);
14
+
15
+ // Add columns
16
+ $table->addColumn('nonce_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
17
+ 'identity' => true,
18
+ 'unsigned' => true,
19
+ 'nullable' => false,
20
+ 'primary' => true
21
+ ));
22
+ $table->addColumn('nonce', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
23
+ 'nullable' => true,
24
+ 'default' => null,
25
+ ));
26
+ $table->addColumn('timestamp', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
27
+ 'unsigned' => true,
28
+ 'nullable' => true,
29
+ 'default' => null,
30
+ ));
31
+ $table->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
32
+ 'unsigned' => true,
33
+ 'nullable' => false,
34
+ ));
35
+
36
+ // Add indexes
37
+ $table->addIndex(
38
+ $installer->getIdxName(
39
+ $nonceTable,
40
+ array('customer_id'),
41
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
42
+ ),
43
+ 'customer_id'
44
+ );
45
+ $table->addIndex(
46
+ $installer->getIdxName(
47
+ $nonceTable,
48
+ array('nonce'),
49
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
50
+ ),
51
+ 'nonce'
52
+ );
53
+ $table->addForeignKey(
54
+ $installer->getFkName($nonceTable, 'customer_id', $customerTable, 'entity_id'),
55
+ 'customer_id',
56
+ $customerTable,
57
+ 'entity_id',
58
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
59
+ Varien_Db_Ddl_Table::ACTION_CASCADE
60
+ );
61
+
62
+ $adapter->createTable($table);
63
+ $installer->endSetup();
app/etc/modules/Navoq_CustomerUniversalPassword.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Navoq_CustomerUniversalPassword>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends/>
8
+ </Navoq_CustomerUniversalPassword>
9
+ </modules>
10
+ </config>
app/locale/en_US/template/email/navoq/customer_universal_password/temporary_link.html ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {* This is a comment block
2
+
3
+ Available vars in this template:
4
+ - $admin_username Admin username
5
+ - $customer_email Customer email
6
+ - $url Unique URL
7
+
8
+ Use vars: {{var var_name}}
9
+ *}
10
+
11
+ Dear {{var admin_username}},</br>
12
+ </br>
13
+ If you want to access "{{var customer_email}}" profile, please follow the link: {{var url}}.
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Navoq_CustomerUniversalPassword</name>
4
+ <version>1.0.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>http://www.opensource.org/licenses/gpl-license.php</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module logs you to front-end of your website as one of your customers, using a universal password.</summary>
10
+ <description>Magento doesn't display customer password in the admin panel. So the only way to know it is to change customer password itself. But it is a bad solution.&#xD;
11
+ &#xD;
12
+ This module logs you to front-end of your website as one of your customers, using a universal password.&#xD;
13
+ &#xD;
14
+ Workflow:&#xD;
15
+ &#xD;
16
+ - Set an universal password in the admin panel. Password is stored as MD5 hash. Nobody can't get it as plain text.&#xD;
17
+ - Set an admin user in the admin panel. This step is needed for sending emails with a unique link for accessing to customers account.&#xD;
18
+ - Try to log in with the universal password. An email with an unique link will be sent to the admin user, which was set in the previous step.&#xD;
19
+ - Open the email and follow the link.</description>
20
+ <notes>This module logs you to front-end of your website as one of your customers, using a universal password.</notes>
21
+ <authors><author><name>Navoq</name><user>Navoq</user><email>navoq.team@gmail.com</email></author></authors>
22
+ <date>2013-01-30</date>
23
+ <time>21:06:42</time>
24
+ <contents><target name="magecommunity"><dir name="Navoq"><dir name="CustomerUniversalPassword"><dir name="Helper"><file name="Data.php" hash="864940407f0c3312b53eb97993f148e2"/><file name="Password.php" hash="7ea69bcc2ae79df89b8b66a2e4498287"/></dir><dir name="Model"><file name="Nonce.php" hash="551855d090c4ba04692746cc941afecf"/><file name="Observer.php" hash="a0162885a2e0afef7028dfc22d82d6cf"/><dir name="Resource"><dir name="Nonce"><file name="Collection.php" hash="77aecf5c55dddd0d6e4aa82e196477f5"/></dir><file name="Nonce.php" hash="ea977bc2b4321ec0383a7c4f953640a5"/><file name="Setup.php" hash="5abc759b26c3066a4e5f1c097a9bd393"/></dir><dir name="Source"><dir name="Settings"><file name="Admin.php" hash="42d003d6ed4313e2820ab048d271a041"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Settings"><dir name="General"><file name="Password.php" hash="8622318db5a63b87c659907d0bd3b154"/></dir></dir></dir></dir></dir></dir><dir name="controllers"><file name="NonceController.php" hash="2f9685b72bb7a5b2e17f88ff2819dd42"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d6bf3421dbcfb12b8505415089ef23fa"/><file name="config.xml" hash="6e85c7578d5b811193f5cd1502d36d15"/><file name="system.xml" hash="3b4104d0f533be5e4010e088ed1ea834"/></dir><dir name="sql"><dir name="navoq_customeruniversalpassword_setup"><file name="install-1.0.0.0.php" hash="b08f5a3ce612df3206288942a8dd9095"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Navoq_CustomerUniversalPassword.xml" hash="6e574013282c93429f882391e9da5896"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="navoq"><dir name="customer_universal_password"><file name="temporary_link.html" hash="57564c03e064ee4f325084010b205618"/></dir></dir></dir></dir></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
27
+ </package>