Version Notes
General performance improvements and support of Magento 1.9 CE and 1.14 EE versions
Download this release
Release Info
Developer | Eversun Software Corp. |
Extension | OAuth_Direct_Login |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
app/code/local/ES/Coreextended/controllers/AuthorizeController.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Extended OAuth Authorize Controller
|
4 |
+
*
|
5 |
+
* The extended OAuth Authorize Controller accepts username and password as part of input parm
|
6 |
+
* without having user to go through the web page to do manual authorization
|
7 |
+
* @category Mage
|
8 |
+
* @package Mage_Oauth
|
9 |
+
* @copyright Copyright (c) 2005-2015 Eversun Software Corporation (http://www.eversunsoft.com)
|
10 |
+
* Class extended from Core_Mage_Oauth
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
require_once Mage::getModuleDir('controllers', 'Mage_Oauth') . DS . 'AuthorizeController.php';
|
14 |
+
class ES_CoreExtended_AuthorizeController extends Mage_Oauth_AuthorizeController
|
15 |
+
{
|
16 |
+
|
17 |
+
protected function _initForm($simple = false)
|
18 |
+
{
|
19 |
+
$server = Mage::getModel('oauth/server');
|
20 |
+
$session = Mage::getSingleton($this->_sessionName);
|
21 |
+
$isException = false;
|
22 |
+
try {
|
23 |
+
$server->checkAuthorizeRequest();
|
24 |
+
} catch (Mage_Core_Exception $e) {
|
25 |
+
$session->addError($e->getMessage());
|
26 |
+
} catch (Mage_Oauth_Exception $e) {
|
27 |
+
$isException = true;
|
28 |
+
$session->addException($e, $this->__('An error occurred. Your authorization request is invalid.'));
|
29 |
+
} catch (Exception $e) {
|
30 |
+
$isException = true;
|
31 |
+
$session->addException($e, $this->__('An error occurred.'));
|
32 |
+
}
|
33 |
+
/* check user credentials*/
|
34 |
+
|
35 |
+
Mage::app('default');
|
36 |
+
umask(0);
|
37 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
38 |
+
|
39 |
+
$session = Mage::getSingleton('customer/session');
|
40 |
+
|
41 |
+
$session->start();
|
42 |
+
$email = $_GET['username'];
|
43 |
+
$password = $_GET['password'];
|
44 |
+
|
45 |
+
try {
|
46 |
+
$session->login($email, $password);
|
47 |
+
} catch (Mage_Core_Exception $e) {
|
48 |
+
switch ($e->getCode()) {
|
49 |
+
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
|
50 |
+
$value = Mage::helper('customer')->getEmailConfirmationUrl($email);
|
51 |
+
$message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
|
52 |
+
break;
|
53 |
+
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
|
54 |
+
$message = $e->getMessage();
|
55 |
+
break;
|
56 |
+
default:
|
57 |
+
$message = $e->getMessage();
|
58 |
+
}
|
59 |
+
$session->addError($message);
|
60 |
+
|
61 |
+
} catch (Exception $e) {
|
62 |
+
|
63 |
+
Mage::logException($e);
|
64 |
+
}
|
65 |
+
|
66 |
+
$logged = $session->isLoggedIn();
|
67 |
+
if ($logged)
|
68 |
+
{
|
69 |
+
$helper = Mage::helper('oauth');
|
70 |
+
$session = Mage::getSingleton($this->_sessionName);
|
71 |
+
|
72 |
+
try {
|
73 |
+
$server = Mage::getModel('oauth/server');
|
74 |
+
$token = $server->authorizeToken($session->getCustomerId(), Mage_Oauth_Model_Token::USER_TYPE_CUSTOMER);
|
75 |
+
if (($callback = $helper->getFullCallbackUrl($token)))
|
76 |
+
{
|
77 |
+
$this->_redirectUrl($callback . ($simple ? '&simple=1' : ''));
|
78 |
+
return $this;
|
79 |
+
} else {
|
80 |
+
$block->setVerifier($token->getVerifier());
|
81 |
+
$session->addSuccess($this->__('Authorization confirmed.'));
|
82 |
+
}
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$session->addError($e->getMessage());
|
85 |
+
} catch (Mage_Oauth_Exception $e) {
|
86 |
+
$session->addException($e, $this->__('An error occurred. Your authorization request is invalid.'));
|
87 |
+
} catch (Exception $e) {
|
88 |
+
$session->addException($e, $this->__('An error occurred on confirm authorize.'));
|
89 |
+
}
|
90 |
+
|
91 |
+
$this->_initLayoutMessages($this->_sessionName);
|
92 |
+
$this->renderLayout();
|
93 |
+
|
94 |
+
return $this;
|
95 |
+
} else {
|
96 |
+
$token = $server->checkAuthorizeRequest();
|
97 |
+
$helper = Mage::helper('oauth');
|
98 |
+
$callback = $helper->getFullCallbackUrl($token, true);
|
99 |
+
$this->_redirectUrl($callback . '&siteCredError=1' );
|
100 |
+
return $this;
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
/*
|
106 |
+
override base index function
|
107 |
+
* */
|
108 |
+
public function indexAction()
|
109 |
+
{
|
110 |
+
$this->_initForm();
|
111 |
+
$this->_initLayoutMessages($this->_sessionName);
|
112 |
+
$this->renderLayout();
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
app/code/local/ES/Coreextended/etc/config.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ES_Coreextended>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</ES_Coreextended>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<oauth>
|
11 |
+
<args>
|
12 |
+
<modules>
|
13 |
+
<ES_Coreextended before="Mage_Oauth">ES_Coreextended</ES_Coreextended>
|
14 |
+
</modules>
|
15 |
+
</args>
|
16 |
+
</oauth>
|
17 |
+
</routers>
|
18 |
+
</frontend>
|
19 |
+
|
20 |
+
</config>
|
app/etc/modules/ES_Coreextended.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ES_Coreextended>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ES_Coreextended>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>OAuth_Direct_Login</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>REST API oauth direct login extension is to avoid manual login during the oauth authentication process.</summary>
|
10 |
+
<description>Magento REST API oauth direct login extension is designed to accept username and password as part of parm during authentication process and automatically login specified user account without redirecting to user login page.
|
11 |
+

|
12 |
+
<p>You can download the following example to learn how to use the REST API oauth direct login module:
|
13 |
+
<a href="http://www.eversunsoft.com/demo/getOauthAccessKeyAndSecret.zip">download the sample code</a>
|
14 |
+
</p>
|
15 |
+
<p>
|
16 |
+
Sample usage(return oAuth Access Token and Access Secret):
|
17 |
+

|
18 |
+
getOauthAccessKeyAndSecret('oauth_consumer_key','oauth_consumer_secret','login_email','login_password','https://your-domain.com/');
|
19 |
+

|
20 |
+
</p></description>
|
21 |
+
<notes>General performance improvements and support of Magento 1.9 CE and 1.14 EE versions</notes>
|
22 |
+
<authors><author><name>Eversun Software Corp.</name><user>eversun</user><email>support@eversunsoft.com</email></author></authors>
|
23 |
+
<date>2015-11-27</date>
|
24 |
+
<time>21:45:10</time>
|
25 |
+
<contents><target name="mageetc"><dir name="modules"><file name="ES_Coreextended.xml" hash="e9ecd409de96aa1b78cffe6c59c1cb4d"/></dir></target><target name="magelocal"><dir name="ES"><dir name="Coreextended"><dir name="controllers"><file name="AuthorizeController.php" hash="f576a332b51df19d83a3232afca89472"/></dir><dir name="etc"><file name="config.xml" hash="ed836650237cb9ac1b02faaeba5b18ae"/></dir></dir></dir></target></contents>
|
26 |
+
<compatible/>
|
27 |
+
<dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php></required></dependencies>
|
28 |
+
</package>
|