Web4pro_Emailauthorization - Version 1.0.0

Version Notes

This module allows the user to sign in his account easier. He just needs to enter an email address and then confirm his login, following the link with a token in the email. The link is temporary. It's available during the certain time.

Download this release

Release Info

Developer Web4pro
Extension Web4pro_Emailauthorization
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Web4pro/Emailauthorization/Block/Emailauth.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Web4pro_Emailauthorization_Block_Emailauth extends Mage_Core_Block_Template
4
+ {
5
+ public function _prepareLayout()
6
+ {
7
+ return parent::_prepareLayout();
8
+ }
9
+
10
+ public function getEmailauthPostUrl()
11
+ {
12
+ return Mage::getUrl('emailauth/index/checkemail');
13
+ }
14
+
15
+ public function canShow()
16
+ {
17
+ if ($this->helper('web4proemailauth')->getConfig('showloginblock')) {
18
+ return true;
19
+ } else {
20
+ return false;
21
+ }
22
+ }
23
+
24
+ }
app/code/community/Web4pro/Emailauthorization/Helper/Data.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Web4pro_Emailauthorization_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function getCustomerByEmail($email)
6
+ {
7
+ $customer = Mage::getModel("customer/customer");
8
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
9
+ $customer->loadByEmail($email);
10
+
11
+ return $customer;
12
+ }
13
+
14
+ public function getCustomerById($id)
15
+ {
16
+ $customer = Mage::getModel("customer/customer");
17
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
18
+ $customer->load($id);
19
+
20
+ return $customer;
21
+ }
22
+
23
+ public function sendEmail($mailInfo = array(), $bodyData = array())
24
+ {
25
+ $emailTplVar = array(
26
+ 'token_url' => Mage::getUrl('emailauth/index/checktoken', array('token' => $bodyData['token'])),
27
+ 'tokenlifetime' => $bodyData['tokenlifetime'],
28
+ );
29
+
30
+ $mailer = Mage::getModel('core/email_template_mailer');
31
+ $emailInfo = Mage::getModel('core/email_info');
32
+ $emailInfo->addTo($mailInfo['email'], $mailInfo['fullname']);
33
+ $mailer->addEmailInfo($emailInfo);
34
+
35
+ $mailer->setSender('general');
36
+ $mailer->setStoreId(Mage::app()->getStore()->getId());
37
+ if (version_compare(Mage::getVersion(), '1.9.1') > 0) {
38
+ // app/locale/en_US/template/email/web4proemailauth/token_email.html
39
+ $mailer->setTemplateId('web4proemailauth_email_template'); // Magento >= 1.9.1
40
+ } else {
41
+ $mailer->setTemplateId('web4proemailauth_email_template_v18'); // Magento <= 1.8
42
+ }
43
+ $mailer->setTemplateParams($emailTplVar);
44
+ $mailer->send();
45
+ }
46
+
47
+ public function getConfig($field = '', $group = 'general', $section = 'web4proemailauth')
48
+ {
49
+ if (empty($field)) {
50
+ return null;
51
+ }
52
+
53
+ return Mage::getStoreConfig("{$section}/{$group}/$field");
54
+ }
55
+
56
+ public function getEmailConfirmationUrl($email = null)
57
+ {
58
+ return Mage::getUrl('customer/account/confirmation', array('email' => $email));
59
+ }
60
+
61
+ }
app/code/community/Web4pro/Emailauthorization/Model/Emailauth.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Web4pro_Emailauthorization_Model_Emailauth extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('web4proemailauth/emailauth');
10
+ }
11
+
12
+ }
app/code/community/Web4pro/Emailauthorization/Model/Resource/Emailauth.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Web4pro_Emailauthorization_Model_Resource_Emailauth extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('web4proemailauth/emailauthorization', 'id');
9
+ }
10
+
11
+ }
app/code/community/Web4pro/Emailauthorization/Model/Resource/Emailauth/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Web4pro_Emailauthorization_Model_Resource_Emailauth_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('web4proemailauth/emailauth');
10
+ }
11
+
12
+ }
app/code/community/Web4pro/Emailauthorization/controllers/IndexController.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once('app/code/core/Mage/Customer/controllers/AccountController.php');
4
+
5
+ class Web4pro_Emailauthorization_IndexController extends Mage_Customer_AccountController
6
+ {
7
+ public function preDispatch()
8
+ {
9
+ Mage_Core_Controller_Front_Action::preDispatch();
10
+
11
+ if (!$this->getRequest()->isDispatched()) {
12
+ return;
13
+ }
14
+
15
+ $action = strtolower($this->getRequest()->getActionName());
16
+ // Allow current actions only
17
+ $openActions = array(
18
+ 'checkemail',
19
+ 'checktoken',
20
+ );
21
+ $pattern = '/^(' . implode('|', $openActions) . ')/i';
22
+
23
+ if (!preg_match($pattern, $action)) {
24
+ if (!$this->_getSession()->authenticate($this)) {
25
+ $this->setFlag('', 'no-dispatch', true);
26
+ }
27
+ } else {
28
+ $this->_getSession()->setNoReferer(true);
29
+ }
30
+ }
31
+
32
+ public function checkemailAction()
33
+ {
34
+ $redirect_url = $this->getDefaultRedirect();
35
+
36
+ if ($this->_getSession()->isLoggedIn()) {
37
+ $this->_redirect($redirect_url);
38
+ return;
39
+ }
40
+ $session = $this->_getSession();
41
+
42
+ if ($this->getRequest()->isPost()) {
43
+ $email = trim($this->getRequest()->getPost('email'));
44
+ if (!empty($email)) {
45
+ $customer = $this->helper()->getCustomerByEmail($email);
46
+
47
+ if (!$customer->getId()) {
48
+ $session->addError($this->__('Email does not exist.'));
49
+ $this->_redirect($redirect_url);
50
+ return;
51
+ }
52
+ if (!$customer->getIsActive()) {
53
+ $session->addError($this->__('Accaunt is inactive.'));
54
+ $this->_redirect($redirect_url);
55
+ return;
56
+ }
57
+
58
+ $token = md5($customer->getEmail() . time() . rand());
59
+
60
+ $emailauth = Mage::getModel('web4proemailauth/emailauth');
61
+ $emailauth->setData(array(
62
+ 'token' => $token,
63
+ 'customer_id' => $customer->getId(),
64
+ 'expiration' => time() + ($this->helper()->getConfig('tokenlifetime') * 60),
65
+ ));
66
+ $emailauth->save();
67
+
68
+
69
+ $mailInfo = array(
70
+ 'email' => $email,
71
+ 'fullname' => $customer->getFirstname() . ' ' . $customer->getLastname(),
72
+ );
73
+ $bodyData = array(
74
+ 'token' => $token,
75
+ 'tokenlifetime' => $this->helper()->getConfig('tokenlifetime'),
76
+ );
77
+ $this->helper()->sendEmail($mailInfo, $bodyData);
78
+
79
+ $session->addSuccess($this->__("Email with Sign In link was sent to `{$email}`."));
80
+ $this->_redirect($redirect_url);
81
+
82
+ } else {
83
+ $session->addError($this->__('Email is required.'));
84
+ $this->_redirect($redirect_url);
85
+ return;
86
+ }
87
+ }
88
+ }
89
+
90
+ public function checktokenAction()
91
+ {
92
+ $redirect_url = $this->getDefaultRedirect();
93
+ $session = $this->_getSession();
94
+ $token = $this->getRequest()->getParam('token');
95
+
96
+ if (empty($token)) {
97
+ $session->addError($this->__('Token is empty'));
98
+ $this->_redirect($redirect_url);
99
+ return;
100
+ }
101
+
102
+ $emailauth = Mage::getModel('web4proemailauth/emailauth');
103
+ $emailauth->load($token, 'token');
104
+
105
+ if (!$emailauth->getId()) {
106
+ $session->addError($this->__('Token was not found'));
107
+ $this->_redirect($redirect_url);
108
+ return;
109
+ }
110
+ if (time() > strtotime($emailauth->getExpiration())) {
111
+ $session->addError($this->__('Login link is expired'));
112
+ $this->_redirect($redirect_url);
113
+ return;
114
+ }
115
+
116
+ $customer = $this->helper()->getCustomerById($emailauth->getCustomerId());
117
+ $email = $customer->getEmail();
118
+
119
+ try {
120
+ $session->setCustomerAsLoggedIn($customer);
121
+ if ($session->getCustomer()->getIsJustConfirmed()) {
122
+ $this->_welcomeCustomer($session->getCustomer(), true);
123
+ }
124
+ } catch (Mage_Core_Exception $e) {
125
+ switch ($e->getCode()) {
126
+ case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
127
+ $value = $this->helper()->getEmailConfirmationUrl($email);
128
+ $message = $this->helper()->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
129
+ break;
130
+ case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
131
+ $message = $e->getMessage();
132
+ break;
133
+ default:
134
+ $message = $e->getMessage();
135
+ }
136
+ $session->addError($message);
137
+ $session->setUsername($email);
138
+ } catch (Exception $e) {
139
+ // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
140
+ }
141
+
142
+ $this->_loginPostRedirect();
143
+ }
144
+
145
+
146
+ private function helper()
147
+ {
148
+ return Mage::helper('web4proemailauth');
149
+ }
150
+
151
+ private function getDefaultRedirect()
152
+ {
153
+ return 'customer/account/login';
154
+ }
155
+
156
+ }
app/code/community/Web4pro/Emailauthorization/etc/adminhtml.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Email authorization feature
5
+ *
6
+ * @author WEB4PRO <achernyshev@web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Emailauthorization
9
+ * @copyright Copyright (c) 2016 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <acl>
15
+ <resources>
16
+ <all>
17
+ <title>Allow Everything</title>
18
+ </all>
19
+ <admin>
20
+ <children>
21
+ <web4pro_attachments>
22
+ <title>Web4pro</title>
23
+ <sort_order>0</sort_order>
24
+ </web4pro_attachments>
25
+ <system>
26
+ <children>
27
+ <config>
28
+ <children>
29
+ <web4proemailauth translate="title">
30
+ <title>Email Authorization</title>
31
+ <sort_order>100</sort_order>
32
+ </web4proemailauth>
33
+ </children>
34
+ </config>
35
+ </children>
36
+ </system>
37
+ </children>
38
+ </admin>
39
+ </resources>
40
+ </acl>
41
+ </config>
app/code/community/Web4pro/Emailauthorization/etc/config.xml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Email authorization feature
5
+ *
6
+ * @author WEB4PRO <achernyshev@web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Emailauthorization
9
+ * @copyright Copyright (c) 2016 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Web4pro_Emailauthorization>
16
+ <version>0.0.1</version>
17
+ </Web4pro_Emailauthorization>
18
+ </modules>
19
+ <frontend>
20
+ <layout>
21
+ <updates>
22
+ <web4proemailauth>
23
+ <file>web4pro_emailauthorization.xml</file>
24
+ </web4proemailauth>
25
+ </updates>
26
+ </layout>
27
+ <routers>
28
+ <web4proemailauth>
29
+ <use>standard</use>
30
+ <args>
31
+ <module>Web4pro_Emailauthorization</module>
32
+ <frontName>emailauth</frontName>
33
+ </args>
34
+ </web4proemailauth>
35
+ </routers>
36
+ </frontend>
37
+ <global>
38
+ <blocks>
39
+ <web4proemailauth>
40
+ <class>Web4pro_Emailauthorization_Block</class>
41
+ </web4proemailauth>
42
+ </blocks>
43
+ <helpers>
44
+ <web4proemailauth>
45
+ <class>Web4pro_Emailauthorization_Helper</class>
46
+ </web4proemailauth>
47
+ </helpers>
48
+ <models>
49
+ <web4proemailauth>
50
+ <class>Web4pro_Emailauthorization_Model</class>
51
+ <resourceModel>web4proemailauth_resource</resourceModel>
52
+ </web4proemailauth>
53
+ <web4proemailauth_resource>
54
+ <class>Web4pro_Emailauthorization_Model_Resource</class>
55
+ <entities>
56
+ <emailauthorization>
57
+ <table>web4pro_emailauthorization_entities</table>
58
+ </emailauthorization>
59
+ </entities>
60
+ </web4proemailauth_resource>
61
+ </models>
62
+ <resources>
63
+ <web4proemailauth_setup>
64
+ <setup>
65
+ <module>Web4pro_Emailauthorization</module>
66
+ </setup>
67
+ </web4proemailauth_setup>
68
+ </resources>
69
+ <template>
70
+ <email>
71
+ <web4proemailauth_email_template module="Web4pro_Emailauthorization">
72
+ <label>Authorization Email</label>
73
+ <!-- app/locale/en_US/template/email/web4proemailauth/token_email.html -->
74
+ <file>web4proemailauth/token_email.html</file>
75
+ <type>html</type>
76
+ </web4proemailauth_email_template>
77
+ <web4proemailauth_email_template_v18 module="Web4pro_Emailauthorization">
78
+ <label>Authorization Email</label>
79
+ <file>web4proemailauth/token_email_v18.html</file>
80
+ <type>html</type>
81
+ </web4proemailauth_email_template_v18>
82
+ </email>
83
+ </template>
84
+ </global>
85
+ <default>
86
+ <web4proemailauth>
87
+ <general>
88
+ <tokenlifetime>60</tokenlifetime>
89
+ <showloginblock>1</showloginblock>
90
+ </general>
91
+ </web4proemailauth>
92
+ </default>
93
+ </config>
app/code/community/Web4pro/Emailauthorization/etc/system.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Email authorization feature
5
+ *
6
+ * @author WEB4PRO <m.krainy@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Emailauthorization
9
+ * @copyright Copyright (c) 2016 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <tabs>
15
+ <web4pro translate="label" module="web4proemailauth">
16
+ <label>Web4pro</label>
17
+ <sort_order>2000</sort_order>
18
+ </web4pro>
19
+ </tabs>
20
+ <sections>
21
+ <web4proemailauth translate="label" module="web4proemailauth">
22
+ <class>separator-top</class>
23
+ <label>Email Authorization</label>
24
+ <tab>web4pro</tab>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>100</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <groups>
31
+ <general>
32
+ <label>General Options</label>
33
+ <expanded>1</expanded>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>2</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ <fields>
40
+ <tokenlifetime translate="label">
41
+ <label>Token lifetime</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>10</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <comment>Set Token lifetime in minutes</comment>
48
+ </tokenlifetime>
49
+ <showloginblock translate="label">
50
+ <label>Show login block</label>
51
+ <frontend_type>select</frontend_type>
52
+ <source_model>adminhtml/system_config_source_yesno</source_model>
53
+ <sort_order>15</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ <comment>Allow to show the block on login page</comment>
58
+ </showloginblock>
59
+ </fields>
60
+ </general>
61
+ </groups>
62
+ </web4proemailauth>
63
+ </sections>
64
+ </config>
app/code/community/Web4pro/Emailauthorization/sql/web4proemailauth_setup/install-0.0.1.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $tableEmailAuth = $installer->getTable('web4proemailauth/emailauthorization');
5
+
6
+ $installer->startSetup();
7
+
8
+ $installer->getConnection()->dropTable($tableEmailAuth);
9
+ $table = $installer->getConnection()
10
+ ->newTable($tableEmailAuth)
11
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
12
+ 'identity' => true,
13
+ 'nullable' => false,
14
+ 'primary' => true,
15
+ ))
16
+ ->addColumn('token', Varien_Db_Ddl_Table::TYPE_TEXT, '64', array(
17
+ 'nullable' => false,
18
+ ))
19
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, '', array(
20
+ 'nullable' => false,
21
+ ))
22
+ ->addColumn('expiration', Varien_Db_Ddl_Table::TYPE_TIME, '', array(
23
+ 'nullable' => false,
24
+ ));
25
+ $installer->getConnection()->createTable($table);
26
+
27
+ $installer->endSetup();
app/design/frontend/base/default/layout/web4pro_emailauthorization.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Email authorization feature
5
+ *
6
+ * @author WEB4PRO <achernyshev@web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Emailauthorization
9
+ * @copyright Copyright (c) 2016 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <layout>
14
+ <customer_account_login>
15
+ <reference name="head">
16
+ <action method="addCss"><stylesheet>css/web4pro_emailauthorization.css</stylesheet></action>
17
+ </reference>
18
+ <reference name="content">
19
+ <block type="web4proemailauth/emailauth" after="customer_form_login" template="web4pro_emailauthorization/emailauth.phtml"/>
20
+ </reference>
21
+ </customer_account_login>
22
+ </layout>
app/design/frontend/base/default/template/web4pro_emailauthorization/emailauth.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->canShow()) { ?>
2
+ <div id="b-email-auth" class="col2-set">
3
+ <div class="b-content b-col-2">
4
+ <h2><?php echo $this->__('Email authorization') ?></h2>
5
+ <form action="<?php echo $this->getEmailauthPostUrl() ?>" method="post" id="email-auth-form">
6
+ <div class="block-content">
7
+ <div class="b-input-box">
8
+ <input type="email" spellcheck="false" name="email"
9
+ title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sign in with email')) ?>"
10
+ class="input-text required-entry validate-email"/>
11
+ </div>
12
+ <div class="b-actions">
13
+ <button type="submit" title="<?php echo $this->__('Send') ?>" class="button">
14
+ <span><span><?php echo $this->__('Send') ?></span></span>
15
+ </button>
16
+ </div>
17
+ </div>
18
+ </form>
19
+ </div>
20
+ </div>
21
+ <?php } ?>
app/design/frontend/rwd/default/template/web4pro_emailauthorization/emailauth.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->canShow()) { ?>
2
+ <div id="email-auth" class="col2-set">
3
+ <div class="block-emailauth col-2">
4
+ <div class="block-title">
5
+ <strong><span><?php echo $this->__('Email authorization') ?></span></strong>
6
+ </div>
7
+ <form action="<?php echo $this->getEmailauthPostUrl() ?>" method="post" id="email-auth-form">
8
+ <div class="block-content">
9
+ <div class="input-box">
10
+ <input type="email" spellcheck="false" name="email"
11
+ title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sign in with email')) ?>"
12
+ class="input-text required-entry validate-email"/>
13
+ </div>
14
+ <div class="actions">
15
+ <button type="submit" title="<?php echo $this->__('Send') ?>" class="button">
16
+ <span><span><?php echo $this->__('Send') ?></span></span>
17
+ </button>
18
+ </div>
19
+ </div>
20
+ </form>
21
+ </div>
22
+ </div>
23
+ <?php } ?>
app/etc/modules/Web4pro_Emailauthorization.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Creating profitable online stores
5
+ *
6
+ * @author WEB4PRO <m.krainy@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Emailauthorization
9
+ * @copyright Copyright (c) 2016 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Web4pro_Emailauthorization>
16
+ <active>true</active>
17
+ <codePool>community</codePool>
18
+ </Web4pro_Emailauthorization>
19
+ </modules>
20
+ </config>
app/locale/en_US/template/email/web4proemailauth/token_email.html ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Authorize with email @-->
2
+
3
+ {{template config_path="design/email/header"}}
4
+ {{inlinecss file="email-inline.css"}}
5
+
6
+ <table cellpadding="0" cellspacing="0" border="0">
7
+ <tr>
8
+ <td class="action-content">
9
+ <h1>Sign in with email</h1>
10
+ <p>Check your mailbox and follow the link to sing in.</p>
11
+ <p>The link is available during {{var tokenlifetime}} minutes.</p>
12
+ <table cellspacing="0" cellpadding="0" class="action-button" >
13
+ <tr>
14
+ <td>
15
+ <a href="{{var token_url}}"><span>Sing in now</span></a>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ </td>
20
+ </tr>
21
+ </table>
22
+
23
+ {{template config_path="design/email/footer"}}
app/locale/en_US/template/email/web4proemailauth/token_email_v18.html ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Authorize with email @-->
2
+
3
+ <!--@styles
4
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
5
+ @-->
6
+
7
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
8
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
9
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
10
+ <tr>
11
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
12
+ <!-- [ header starts here] -->
13
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650"
14
+ style="border:1px solid #E0E0E0;">
15
+ <tr>
16
+ <td valign="top">
17
+ <h1>Sign in with email</h1>
18
+ </td>
19
+ </tr>
20
+ <!-- [ middle starts here] -->
21
+ <tr>
22
+ <td valign="top">
23
+ <p>Check your mailbox and follow the link to sing in.</p>
24
+ <p>The link is available during {{var tokenlifetime}} minutes.</p>
25
+ <table cellspacing="0" cellpadding="0" class="action-button">
26
+ <tr>
27
+ <td>
28
+ <a href="{{var token_url}}"><span>Sing in now</span></a>
29
+ </td>
30
+ </tr>
31
+ </table>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;">
36
+ <center>
37
+ <p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p>
38
+ </center>
39
+ </td>
40
+ </tr>
41
+ </table>
42
+ </td>
43
+ </tr>
44
+ </table>
45
+ </div>
46
+ </body>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Web4pro_Emailauthorization</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Adds a possibility of login without a password. A user enters an email address and just follows a link with token received on email.</summary>
10
+ <description>This module allows the user to sign in his account easier. He just needs to enter an email address and then confirm his login, following the link with a token in the email. The link is temporary. It's available during the certain time.</description>
11
+ <notes>This module allows the user to sign in his account easier. He just needs to enter an email address and then confirm his login, following the link with a token in the email. The link is temporary. It's available during the certain time.</notes>
12
+ <authors><author><name>Web4pro</name><user>mkrainy</user><email>mkrainy@corp.web4pro.com.ua</email></author></authors>
13
+ <date>2016-04-27</date>
14
+ <time>10:23:27</time>
15
+ <contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Web4pro"><dir name="Emailauthorization"><dir><dir name="Block"><file name="Emailauth.php" hash="00a2f32a43f2c9cb90d9626e7bca1d52"/></dir><dir name="Helper"><file name="Data.php" hash="5c06bf003ca950342b9e55b36e8163b7"/></dir><dir name="Model"><file name="Emailauth.php" hash="d4df55dc82a36ab49764c5bea9510013"/><dir name="Resource"><dir name="Emailauth"><file name="Collection.php" hash="3deedb5b85071b6f124968a239cdac5a"/></dir><file name="Emailauth.php" hash="b5df840b50ddfe0ae18d4d886346b592"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="bffd2b08c80913b56c921e6ad0871c38"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8fd0fc3589c7ba074e3fd4d2bd0d791b"/><file name="config.xml" hash="f50a53df6fee666bf03d6d360d64eafc"/><file name="system.xml" hash="465b2695bf7ae589a21bbc85b542415a"/></dir><dir name="sql"><dir name="web4proemailauth_setup"><file name="install-0.0.1.php" hash="6b8377e21aeb54bf20aaa5692d0f18c7"/></dir></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="web4pro_emailauthorization.xml" hash="c6d73da89b3bcd0716085ecfeaab70ab"/></dir><dir name="template"><dir name="web4pro_emailauthorization"><file name="emailauth.phtml" hash="14b2df50691be8666e7cad98e2051862"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="template"><dir name="web4pro_emailauthorization"><file name="emailauth.phtml" hash="a5ce4f57a182e7d87fe88f1aa600fc3b"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Web4pro_Emailauthorization.xml" hash="841985c64906b2962a35e0b1b68cc4fa"/></dir></dir><dir name="locale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="web4proemailauth"><file name="token_email.html" hash="5612bffac741f4f00582161b954f9f4d"/><file name="token_email_v18.html" hash="19cb8f37feb5d4a7f127bf53d8e9a873"/></dir></dir></dir></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="web4pro_emailauthorization.css" hash="92cb213c0c9daf90f3bc8b258220ef39"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/web4pro_emailauthorization.css ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WEB4PRO - Email authorization feature
3
+ *
4
+ * @author WEB4PRO <m.krainy@web4pro.com.ua>
5
+ * @category WEB4PRO
6
+ * @package Web4pro_Emailauthorization
7
+ * @copyright Copyright (c) 2016 WEB4PRO (http://www.web4pro.net)
8
+ * @license http://www.web4pro.net/license.txt
9
+ */
10
+
11
+ /*
12
+ * default styles
13
+ */
14
+ #b-email-auth {
15
+ margin-top: 20px;
16
+ }
17
+
18
+ #b-email-auth h2 {
19
+ background-position: 0 1px;
20
+ background-repeat: no-repeat;
21
+ border-bottom: 1px solid #ddd;
22
+ color: #e76200;
23
+ font-size: 13px;
24
+ font-weight: bold;
25
+ margin: 0 0 14px;
26
+ padding: 0 0 5px 23px;
27
+ text-transform: uppercase;
28
+ background-image: url("../../../default/default/images/i_page2.gif");
29
+ }
30
+
31
+ #b-email-auth .b-content {
32
+ padding: 14px 21px;
33
+ background: #faf7ee url("../../../default/default/images/bkg_login-box.gif") repeat-x scroll 0 0;
34
+ border-color: #bbb6a5;
35
+ border-style: solid;
36
+ border-width: 1px;
37
+ }
38
+
39
+ #b-email-auth .b-col-2 {
40
+ float: right;
41
+ width: 43.6%;
42
+ }
43
+
44
+ #b-email-auth .b-input-box {
45
+ float: left;
46
+ padding-top: 0;
47
+ width: 344px;
48
+ }
49
+ #b-email-auth .b-input-box input {
50
+ width: 96%;
51
+ }
52
+
53
+ #b-email-auth .b-actions {
54
+ float: left;
55
+ margin: 0;
56
+ }
57
+
58
+ /*
59
+ * Rwd styles
60
+ */
61
+ .block-emailauth .input-box {
62
+ float: left;
63
+ padding-top: 0;
64
+ width: 365px;
65
+ }
66
+
67
+ .block-emailauth .actions {
68
+ float: left;
69
+ margin: 0;
70
+ }
71
+
72
+ .block-emailauth .actions button {
73
+ line-height: 16px;
74
+ }
75
+