Version Notes
http://developers.gigya.com/display/NEX/Change+Log+-+Magento+1.x
Download this release
Release Info
Developer | Yaniv Aran-Shamir |
Extension | Gigya_Socialize |
Version | 3.2.3 |
Comparing to | |
See all releases |
Code changes from version 3.2.0 to 3.2.3
- app/code/community/Gigya/Social/Block/Adminhtml/RaasTitles.php +4 -0
- app/code/community/Gigya/Social/Block/Raas/ScreenSets.php +43 -0
- app/code/community/Gigya/Social/Helper/Data.php +29 -4
- app/code/community/Gigya/Social/Helper/FieldMapping/Conf.php +3 -3
- app/code/community/Gigya/Social/Helper/FieldMapping/GigyaUpdater.php +19 -23
- app/code/community/Gigya/Social/Helper/FieldMapping/MagentoUpdater.php +26 -24
- app/code/community/Gigya/Social/Helper/FieldMapping/Updater.php +70 -0
- app/code/community/Gigya/Social/Model/Config/Backend/ApiKey.php +3 -3
- app/code/community/Gigya/Social/Model/Config/Source/Lead.php +19 -0
- app/code/community/Gigya/Social/Model/Customer/Observer.php +127 -43
- app/code/community/Gigya/Social/controllers/LoginController.php +659 -625
- app/code/community/Gigya/Social/etc/config.xml +13 -3
- app/code/community/Gigya/Social/etc/mappings.json +6 -0
- app/code/community/Gigya/Social/etc/system.xml +9 -0
- app/code/community/Gigya/Social/sdk/gigyaCMS.php +36 -35
- app/code/community/Gigya/Social/tests/TestGigyaCms.php +0 -65
- app/code/community/Gigya/Social/tests/adminTests/GigyaUpdaterTest.php +0 -90
- app/code/community/Gigya/Social/tests/adminTests/TestApiKeyValidation.php +0 -66
- app/code/community/Gigya/Social/tests/adminTests/TestDefaultValues.php +0 -22
- app/code/community/Gigya/Social/tests/bootstrap.php +0 -25
- app/code/community/Gigya/Social/tests/frontendTests/Gigya_Social_AccountControllerTest.php +0 -18
- app/code/community/Gigya/Social/tests/frontendTests/MagentoUpdaterTest.php +0 -79
- app/code/community/Gigya/Social/tests/phpunit.xml +0 -15
- app/code/community/Gigya/Social/tests/resources/account.json +0 -93
- app/code/community/Gigya/Social/tests/resources/mappings.json +0 -16
- app/code/community/Gigya/Social/tests/resources/mappings_array.json +0 -8
- app/code/community/Gigya/Social/tests/resources/mappings_casting.json +0 -33
- app/code/community/Gigya/Social/tests/resources/mappings_casting_to_gigya.json +0 -27
- app/code/community/Gigya/Social/tests/resources/mappings_deep.json +0 -8
- app/design/frontend/base/default/template/gigya/raas/onepage/screenset.phtml +30 -0
- app/design/frontend/base/default/template/gigya/raas/screenset.phtml +24 -0
- js/gigya/gigyaMagento.js +22 -8
- package.xml +5 -5
app/code/community/Gigya/Social/Block/Adminhtml/RaasTitles.php
CHANGED
@@ -19,6 +19,10 @@ class Gigya_Social_Block_Adminhtml_RaasTitles extends Mage_Adminhtml_Block_Syste
|
|
19 |
case "gigya_login_gigya_raas_conf_div_ids_title":
|
20 |
return (string) '<span style="font-size: 14px;"><b>DIV IDs</b></span>';
|
21 |
break;
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
}
|
24 |
|
19 |
case "gigya_login_gigya_raas_conf_div_ids_title":
|
20 |
return (string) '<span style="font-size: 14px;"><b>DIV IDs</b></span>';
|
21 |
break;
|
22 |
+
case "gigya_login_gigya_raas_conf_session_lead_title":
|
23 |
+
return (string) '<span style="font-size: 14px;"><b>Session management - (Applies only to RaaS)</b></span>';
|
24 |
+
break;
|
25 |
+
|
26 |
}
|
27 |
}
|
28 |
|
app/code/community/Gigya/Social/Block/Raas/ScreenSets.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PhpStorm.
|
5 |
+
* User: Yaniv Aran-Shamir
|
6 |
+
* Date: 7/24/16
|
7 |
+
* Time: 12:07 PM
|
8 |
+
*/
|
9 |
+
class Gigya_Social_Block_Raas_ScreenSets extends Mage_Core_Block_Template
|
10 |
+
{
|
11 |
+
|
12 |
+
protected function _beforeToHtml()
|
13 |
+
{
|
14 |
+
$params = $this->getData("params");
|
15 |
+
if (count($params) > 0) {
|
16 |
+
$embed = isset($params['containerID']);
|
17 |
+
$this->setEmbed($embed);
|
18 |
+
if (!$embed) {
|
19 |
+
$linkText = empty($params['text'])
|
20 |
+
? "Please add the text parameter to the block" : $params['text'];
|
21 |
+
$html = '<a class="gigya-screenset-link" onclick="showScreens()" href="#">' . $linkText . '</a>';
|
22 |
+
} else {
|
23 |
+
$html = '<div id="' . $params['containerID'] . '"></div>';
|
24 |
+
}
|
25 |
+
unset($params['text']);
|
26 |
+
$jsParams = json_encode($params);
|
27 |
+
$this->setParams($jsParams);
|
28 |
+
$this->setHtml($html);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* For onepage checkout
|
34 |
+
* Retrieve is allow and show block
|
35 |
+
*
|
36 |
+
* @return bool
|
37 |
+
*/
|
38 |
+
public function isShow()
|
39 |
+
{
|
40 |
+
return true;
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
app/code/community/Gigya/Social/Helper/Data.php
CHANGED
@@ -222,6 +222,35 @@ class Gigya_Social_Helper_Data extends Mage_Core_Helper_Abstract
|
|
222 |
}
|
223 |
}
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
/*
|
226 |
* Logout user from Gigya
|
227 |
* called by notify_logout customer observer
|
@@ -458,10 +487,6 @@ class Gigya_Social_Helper_Data extends Mage_Core_Helper_Abstract
|
|
458 |
$this->utils = new GigyaCMS($this->apiKey, $this->apiSecret, $this->apiDomain, $this->userSecret,
|
459 |
$this->userKey, $this->useUserKey, $this->debug);
|
460 |
}
|
461 |
-
if (null == $this->utils) {
|
462 |
-
|
463 |
-
}
|
464 |
-
|
465 |
return $this->utils;
|
466 |
}
|
467 |
|
222 |
}
|
223 |
}
|
224 |
|
225 |
+
public function accountsNotifyLogin($siteUid, $sessionExpiration = null, $cid = null)
|
226 |
+
{
|
227 |
+
$params = array(
|
228 |
+
'siteUID' => $siteUid,
|
229 |
+
);
|
230 |
+
if (null !== $sessionExpiration) {
|
231 |
+
$params['sessionExpiration'] = $sessionExpiration;
|
232 |
+
}
|
233 |
+
if (null !== $cid) {
|
234 |
+
$params['cid'] = $cid;
|
235 |
+
}
|
236 |
+
try {
|
237 |
+
$res = $this->_gigya_api('accounts.notifyLogin', $params);
|
238 |
+
if (is_array($res) && $res["errorCode"] === 0) {
|
239 |
+
$cookieInfo = $res['sessionInfo'];
|
240 |
+
$sessionExpiration = ($sessionExpiration == null) ? 0 : $sessionExpiration;
|
241 |
+
setcookie($cookieInfo["cookieName"], $cookieInfo["cookieValue"], $_SERVER['REQUEST_TIME'] + $sessionExpiration);
|
242 |
+
return true;
|
243 |
+
} else {
|
244 |
+
Mage::log('Error calling accounts.notifyLogin error code was ' . $res['errorCode']);
|
245 |
+
return false;
|
246 |
+
}
|
247 |
+
} catch (Exception $e) {
|
248 |
+
Mage::logException($e);
|
249 |
+
return false;
|
250 |
+
}
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
/*
|
255 |
* Logout user from Gigya
|
256 |
* called by notify_logout customer observer
|
487 |
$this->utils = new GigyaCMS($this->apiKey, $this->apiSecret, $this->apiDomain, $this->userSecret,
|
488 |
$this->userKey, $this->useUserKey, $this->debug);
|
489 |
}
|
|
|
|
|
|
|
|
|
490 |
return $this->utils;
|
491 |
}
|
492 |
|
app/code/community/Gigya/Social/Helper/FieldMapping/Conf.php
CHANGED
@@ -13,9 +13,9 @@ class Gigya_Social_Helper_FieldMapping_Conf
|
|
13 |
private $gigyaKeyed;
|
14 |
private $mappingConf;
|
15 |
|
16 |
-
public function __construct($
|
17 |
{
|
18 |
-
$this->mappingConf =
|
19 |
}
|
20 |
|
21 |
protected function buildKeyedArrays($array)
|
@@ -25,7 +25,7 @@ class Gigya_Social_Helper_FieldMapping_Conf
|
|
25 |
foreach ($array as $confItem) {
|
26 |
$mageKey = $confItem['magentoName'];
|
27 |
$gigyaKey = $confItem['gigyaName'];
|
28 |
-
$direction = $confItem['direction'];
|
29 |
$conf = new Gigya_Social_Helper_FieldMapping_ConfItem($confItem);
|
30 |
switch ($direction) {
|
31 |
case "g2cms" :
|
13 |
private $gigyaKeyed;
|
14 |
private $mappingConf;
|
15 |
|
16 |
+
public function __construct($confArray)
|
17 |
{
|
18 |
+
$this->mappingConf = $confArray;
|
19 |
}
|
20 |
|
21 |
protected function buildKeyedArrays($array)
|
25 |
foreach ($array as $confItem) {
|
26 |
$mageKey = $confItem['magentoName'];
|
27 |
$gigyaKey = $confItem['gigyaName'];
|
28 |
+
$direction = empty($confItem['direction']) ? "g2cms" : $confItem['direction'];
|
29 |
$conf = new Gigya_Social_Helper_FieldMapping_ConfItem($confItem);
|
30 |
switch ($direction) {
|
31 |
case "g2cms" :
|
app/code/community/Gigya/Social/Helper/FieldMapping/GigyaUpdater.php
CHANGED
@@ -6,14 +6,13 @@
|
|
6 |
* Date: 5/26/16
|
7 |
* Time: 2:05 PM
|
8 |
*/
|
9 |
-
class Gigya_Social_Helper_FieldMapping_GigyaUpdater
|
10 |
{
|
11 |
|
12 |
private $magMappings;
|
13 |
private $cmsArray;
|
14 |
private $gigyaUid;
|
15 |
private $mapped;
|
16 |
-
private $path;
|
17 |
private $gigyaArray;
|
18 |
|
19 |
/**
|
@@ -23,8 +22,8 @@ class Gigya_Social_Helper_FieldMapping_GigyaUpdater
|
|
23 |
{
|
24 |
$this->cmsArray = $cmsValuesArray;
|
25 |
$this->gigyaUid = $gigyaUid;
|
26 |
-
$this->path =
|
27 |
-
$this->mapped = !
|
28 |
|
29 |
}
|
30 |
|
@@ -95,19 +94,9 @@ class Gigya_Social_Helper_FieldMapping_GigyaUpdater
|
|
95 |
$this->gigyaArray = $gigyaArray;
|
96 |
}
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
protected function retrieveFieldMappings()
|
102 |
{
|
103 |
-
$
|
104 |
-
if (false === $mappingJson) {
|
105 |
-
$err = error_get_last();
|
106 |
-
$message = "Could not retrieve field mapping configuration file. message was:" . $err['message'];
|
107 |
-
Mage::log($message, Zend_Log::ERR);
|
108 |
-
throw new Exception("$message");
|
109 |
-
}
|
110 |
-
$conf = new Gigya_Social_Helper_FieldMapping_Conf($mappingJson);
|
111 |
$this->magMappings = $conf->getMagentoKeyed();
|
112 |
}
|
113 |
|
@@ -116,11 +105,15 @@ class Gigya_Social_Helper_FieldMapping_GigyaUpdater
|
|
116 |
$gigyaArray = array();
|
117 |
foreach ($this->cmsArray as $key => $value) {
|
118 |
/** @var Gigya_Social_Helper_FieldMapping_ConfItem $conf */
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
}
|
126 |
}
|
@@ -134,7 +127,6 @@ class Gigya_Social_Helper_FieldMapping_GigyaUpdater
|
|
134 |
$helper->updateGigyaUser($this->gigyaArray, $this->gigyaUid);
|
135 |
}
|
136 |
|
137 |
-
|
138 |
/**
|
139 |
* @param mixed $val
|
140 |
* @param Gigya_Social_Helper_FieldMapping_ConfItem $conf
|
@@ -146,11 +138,11 @@ class Gigya_Social_Helper_FieldMapping_GigyaUpdater
|
|
146 |
{
|
147 |
switch ($conf->getGigyaType()) {
|
148 |
case "string":
|
149 |
-
return (string)
|
150 |
break;
|
151 |
case "long";
|
152 |
case "int":
|
153 |
-
return (int)
|
154 |
break;
|
155 |
case "bool":
|
156 |
if (is_string($val)) {
|
@@ -175,4 +167,8 @@ class Gigya_Social_Helper_FieldMapping_GigyaUpdater
|
|
175 |
$arr = $value;
|
176 |
}
|
177 |
|
|
|
|
|
|
|
|
|
178 |
}
|
6 |
* Date: 5/26/16
|
7 |
* Time: 2:05 PM
|
8 |
*/
|
9 |
+
class Gigya_Social_Helper_FieldMapping_GigyaUpdater extends Gigya_Social_Helper_FieldMapping_Updater
|
10 |
{
|
11 |
|
12 |
private $magMappings;
|
13 |
private $cmsArray;
|
14 |
private $gigyaUid;
|
15 |
private $mapped;
|
|
|
16 |
private $gigyaArray;
|
17 |
|
18 |
/**
|
22 |
{
|
23 |
$this->cmsArray = $cmsValuesArray;
|
24 |
$this->gigyaUid = $gigyaUid;
|
25 |
+
$this->path = Mage::getConfig()->getNode("global/gigya/mapping_file");
|
26 |
+
$this->mapped = !empty($this->path);
|
27 |
|
28 |
}
|
29 |
|
94 |
$this->gigyaArray = $gigyaArray;
|
95 |
}
|
96 |
|
|
|
|
|
|
|
97 |
protected function retrieveFieldMappings()
|
98 |
{
|
99 |
+
$conf = parent::retrieveFieldMappings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
$this->magMappings = $conf->getMagentoKeyed();
|
101 |
}
|
102 |
|
105 |
$gigyaArray = array();
|
106 |
foreach ($this->cmsArray as $key => $value) {
|
107 |
/** @var Gigya_Social_Helper_FieldMapping_ConfItem $conf */
|
108 |
+
if (isset($this->magMappings[$key])) {
|
109 |
+
$confs = $this->magMappings[$key];
|
110 |
+
foreach ($confs as $conf) {
|
111 |
+
$value = $this->castVal($value, $conf);
|
112 |
+
if (null != $value) {
|
113 |
+
$this->assignArrayByPath(
|
114 |
+
$gigyaArray, $conf->getGigyaName(), $value
|
115 |
+
);
|
116 |
+
}
|
117 |
}
|
118 |
}
|
119 |
}
|
127 |
$helper->updateGigyaUser($this->gigyaArray, $this->gigyaUid);
|
128 |
}
|
129 |
|
|
|
130 |
/**
|
131 |
* @param mixed $val
|
132 |
* @param Gigya_Social_Helper_FieldMapping_ConfItem $conf
|
138 |
{
|
139 |
switch ($conf->getGigyaType()) {
|
140 |
case "string":
|
141 |
+
return (string)$val;
|
142 |
break;
|
143 |
case "long";
|
144 |
case "int":
|
145 |
+
return (int)$val;
|
146 |
break;
|
147 |
case "bool":
|
148 |
if (is_string($val)) {
|
167 |
$arr = $value;
|
168 |
}
|
169 |
|
170 |
+
protected function getCacheKey()
|
171 |
+
{
|
172 |
+
return get_class() . '_field_mappings';
|
173 |
+
}
|
174 |
}
|
app/code/community/Gigya/Social/Helper/FieldMapping/MagentoUpdater.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Date: 5/29/16
|
7 |
* Time: 4:47 PM
|
8 |
*/
|
9 |
-
class Gigya_Social_Helper_FieldMapping_MagentoUpdater
|
10 |
{
|
11 |
|
12 |
private $gigyaAccount;
|
@@ -15,7 +15,7 @@ class Gigya_Social_Helper_FieldMapping_MagentoUpdater
|
|
15 |
* @var bool
|
16 |
*/
|
17 |
private $mapped = false;
|
18 |
-
|
19 |
|
20 |
/**
|
21 |
* Gigya_Social_Helper_FieldMapping_MagentoUpdater constructor.
|
@@ -25,8 +25,8 @@ class Gigya_Social_Helper_FieldMapping_MagentoUpdater
|
|
25 |
public function __construct($gigyaAccount)
|
26 |
{
|
27 |
$this->gigyaAccount = $gigyaAccount;
|
28 |
-
$this->path =
|
29 |
-
$this->mapped = !
|
30 |
}
|
31 |
|
32 |
/**
|
@@ -52,22 +52,18 @@ class Gigya_Social_Helper_FieldMapping_MagentoUpdater
|
|
52 |
*/
|
53 |
public function isMapped()
|
54 |
{
|
55 |
-
if (Mage::helper('Gigya_Social')->isDebug()) {
|
56 |
-
Mage::log(
|
|
|
|
|
|
|
57 |
}
|
58 |
return $this->mapped;
|
59 |
}
|
60 |
|
61 |
protected function retrieveFieldMappings()
|
62 |
{
|
63 |
-
$
|
64 |
-
if (false === $mappingJson) {
|
65 |
-
$err = error_get_last();
|
66 |
-
$message = "Could not retrieve field mapping configuration file. message was:" . $err['message'];
|
67 |
-
Mage::log($message, Zend_Log::ERR);
|
68 |
-
throw new Exception("$message");
|
69 |
-
}
|
70 |
-
$conf = new Gigya_Social_Helper_FieldMapping_Conf($mappingJson);
|
71 |
$this->gigyaMapping = $conf->getGigyaKeyed();
|
72 |
}
|
73 |
|
@@ -80,8 +76,8 @@ class Gigya_Social_Helper_FieldMapping_MagentoUpdater
|
|
80 |
/** @var Gigya_Social_Helper_FieldMapping_ConfItem $conf */
|
81 |
$value = $this->getValueFromGigyaAccount($gigyaName);
|
82 |
foreach ($confs as $conf) {
|
83 |
-
$mageKey
|
84 |
-
$value
|
85 |
$account->setData($mageKey, $value);
|
86 |
}
|
87 |
}
|
@@ -120,19 +116,23 @@ class Gigya_Social_Helper_FieldMapping_MagentoUpdater
|
|
120 |
} else {
|
121 |
$value = new Zend_Date($value);
|
122 |
}
|
123 |
-
$value = Mage::helper('core')
|
|
|
|
|
|
|
|
|
124 |
break;
|
125 |
case "decimal":
|
126 |
-
$value = (float)
|
127 |
break;
|
128 |
case "int":
|
129 |
-
$value = (int)
|
130 |
break;
|
131 |
case "text":
|
132 |
-
$value = (string)
|
133 |
break;
|
134 |
case "varchar":
|
135 |
-
$value = (string)
|
136 |
break;
|
137 |
}
|
138 |
|
@@ -186,7 +186,9 @@ class Gigya_Social_Helper_FieldMapping_MagentoUpdater
|
|
186 |
{
|
187 |
$this->gigyaMapping = $gigyaMapping;
|
188 |
}
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
192 |
}
|
6 |
* Date: 5/29/16
|
7 |
* Time: 4:47 PM
|
8 |
*/
|
9 |
+
class Gigya_Social_Helper_FieldMapping_MagentoUpdater extends Gigya_Social_Helper_FieldMapping_Updater
|
10 |
{
|
11 |
|
12 |
private $gigyaAccount;
|
15 |
* @var bool
|
16 |
*/
|
17 |
private $mapped = false;
|
18 |
+
/** @var \Mage_Core_Model_Config_Element */
|
19 |
|
20 |
/**
|
21 |
* Gigya_Social_Helper_FieldMapping_MagentoUpdater constructor.
|
25 |
public function __construct($gigyaAccount)
|
26 |
{
|
27 |
$this->gigyaAccount = $gigyaAccount;
|
28 |
+
$this->path = Mage::getConfig()->getNode("global/gigya/mapping_file");
|
29 |
+
$this->mapped = !empty($this->path);
|
30 |
}
|
31 |
|
32 |
/**
|
52 |
*/
|
53 |
public function isMapped()
|
54 |
{
|
55 |
+
if (!$this->mapped && Mage::helper('Gigya_Social')->isDebug()) {
|
56 |
+
Mage::log(
|
57 |
+
"Field mapping is not enabled", Zend_Log::DEBUG,
|
58 |
+
"gigya_debug_log"
|
59 |
+
);
|
60 |
}
|
61 |
return $this->mapped;
|
62 |
}
|
63 |
|
64 |
protected function retrieveFieldMappings()
|
65 |
{
|
66 |
+
$conf = parent::retrieveFieldMappings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
$this->gigyaMapping = $conf->getGigyaKeyed();
|
68 |
}
|
69 |
|
76 |
/** @var Gigya_Social_Helper_FieldMapping_ConfItem $conf */
|
77 |
$value = $this->getValueFromGigyaAccount($gigyaName);
|
78 |
foreach ($confs as $conf) {
|
79 |
+
$mageKey = $conf->getMagentoName();
|
80 |
+
$value = $this->castValue($value, $conf);
|
81 |
$account->setData($mageKey, $value);
|
82 |
}
|
83 |
}
|
116 |
} else {
|
117 |
$value = new Zend_Date($value);
|
118 |
}
|
119 |
+
$value = Mage::helper('core')
|
120 |
+
->formatDate(
|
121 |
+
$value, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM,
|
122 |
+
false
|
123 |
+
);
|
124 |
break;
|
125 |
case "decimal":
|
126 |
+
$value = (float)$value;
|
127 |
break;
|
128 |
case "int":
|
129 |
+
$value = (int)$value;
|
130 |
break;
|
131 |
case "text":
|
132 |
+
$value = (string)$value;
|
133 |
break;
|
134 |
case "varchar":
|
135 |
+
$value = (string)$value;
|
136 |
break;
|
137 |
}
|
138 |
|
186 |
{
|
187 |
$this->gigyaMapping = $gigyaMapping;
|
188 |
}
|
189 |
+
|
190 |
+
protected function getCacheKey()
|
191 |
+
{
|
192 |
+
return get_class() . '_field_mappings';
|
193 |
+
}
|
194 |
}
|
app/code/community/Gigya/Social/Helper/FieldMapping/Updater.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PhpStorm.
|
5 |
+
* User: Yaniv Aran-Shamir
|
6 |
+
* Date: 8/7/16
|
7 |
+
* Time: 2:04 PM
|
8 |
+
*/
|
9 |
+
require_once Mage::getModuleDir('', 'Gigya_Social') . DS . 'sdk' . DS . 'gigyaCMS.php';
|
10 |
+
abstract class Gigya_Social_Helper_FieldMapping_Updater
|
11 |
+
{
|
12 |
+
|
13 |
+
protected $path;
|
14 |
+
|
15 |
+
protected function retrieveFieldMappings()
|
16 |
+
{
|
17 |
+
/** @var Mage_Core_Model_Cache $cache */
|
18 |
+
$cache = Mage::app()->getCache();
|
19 |
+
$conf = $cache->load($this->getCacheKey());
|
20 |
+
if ($conf === false) {
|
21 |
+
if ($this->path->hasChildren()) {
|
22 |
+
$files = (array)$this->path->children();
|
23 |
+
/** @var array $mappingArray */
|
24 |
+
$mappingArray = array();
|
25 |
+
foreach ($files as $file) {
|
26 |
+
$newMappings = GigyaCMS::parseJSON($this->retrieveFieldMappingsFile($file));
|
27 |
+
if (is_array($newMappings)) {
|
28 |
+
$mappingArray = array_merge($mappingArray, $newMappings);
|
29 |
+
} else {
|
30 |
+
Mage::log('Bad json in file ' . $file . 'error was ' . $newMappings, Zend_Log::ERR);
|
31 |
+
}
|
32 |
+
}
|
33 |
+
} else {
|
34 |
+
$mappingArray = GigyaCMS::parseJSON($this->retrieveFieldMappingsFile(trim((string)$this->path)));
|
35 |
+
if (!is_array($mappingArray)) {
|
36 |
+
Mage::log('Bad json in file ' . (string)$this->path . 'error was ' . $mappingArray, Zend_Log::ERR);
|
37 |
+
$mappingArray = null;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
if (null != $mappingArray) {
|
41 |
+
$conf = new Gigya_Social_Helper_FieldMapping_Conf($mappingArray);
|
42 |
+
$cache->save(serialize($conf), $this->getCacheKey(), array("gigya"), 86400);
|
43 |
+
}
|
44 |
+
} else {
|
45 |
+
$conf = unserialize($conf);
|
46 |
+
}
|
47 |
+
return $conf;
|
48 |
+
}
|
49 |
+
|
50 |
+
abstract protected function getCacheKey();
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param string $filePath
|
54 |
+
*
|
55 |
+
* @return null| string
|
56 |
+
*/
|
57 |
+
private function retrieveFieldMappingsFile($filePath)
|
58 |
+
{
|
59 |
+
$mappingJson = file_get_contents($filePath);
|
60 |
+
if (false === $mappingJson) {
|
61 |
+
$err = error_get_last();
|
62 |
+
$message
|
63 |
+
= "Could not retrieve field mapping configuration file. message was:"
|
64 |
+
. $err['message'];
|
65 |
+
Mage::log($message, Zend_Log::ERR);
|
66 |
+
return null;
|
67 |
+
}
|
68 |
+
return $mappingJson;
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Gigya/Social/Model/Config/Backend/ApiKey.php
CHANGED
@@ -77,9 +77,9 @@ class Gigya_Social_Model_Config_Backend_ApiKey extends Mage_Core_Model_Config_Da
|
|
77 |
|
78 |
protected function shouldRun($useUserKey, $current)
|
79 |
{
|
80 |
-
$apiKeyChanged = $this->hasChanged($this->getFieldsetDataValue("apikey"), $current['apikey']);
|
81 |
-
$dataCenterChanged = $this->hasChanged($this->getFieldsetDataValue("dataCenter"), $current['dataCenter'] );
|
82 |
-
$userKeyChanged = $this->hasChanged($this->getFieldsetDataValue("userKey"), $current['userKey']);
|
83 |
$apiOrDcOrUserKey = $apiKeyChanged || $dataCenterChanged || $userKeyChanged;
|
84 |
if ($useUserKey) {
|
85 |
$secretChanged = $this->getFieldsetDataValue('userSecret') != "******";
|
77 |
|
78 |
protected function shouldRun($useUserKey, $current)
|
79 |
{
|
80 |
+
$apiKeyChanged = $this->hasChanged($this->getFieldsetDataValue("apikey"), isset($current['apikey']) ? $current['apikey'] : "");
|
81 |
+
$dataCenterChanged = $this->hasChanged($this->getFieldsetDataValue("dataCenter"), isset($current['dataCenter']) ? $current['dataCenter'] : "" );
|
82 |
+
$userKeyChanged = $this->hasChanged($this->getFieldsetDataValue("userKey"), isset($current['userKey']) ? $current['userKey'] : "");
|
83 |
$apiOrDcOrUserKey = $apiKeyChanged || $dataCenterChanged || $userKeyChanged;
|
84 |
if ($useUserKey) {
|
85 |
$secretChanged = $this->getFieldsetDataValue('userSecret') != "******";
|
app/code/community/Gigya/Social/Model/Config/Source/Lead.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PhpStorm.
|
5 |
+
* User: Yaniv Aran-Shamir
|
6 |
+
* Date: 9/26/16
|
7 |
+
* Time: 1:05 PM
|
8 |
+
*/
|
9 |
+
class Gigya_Social_Model_Config_Source_Lead
|
10 |
+
{
|
11 |
+
public function toOptionArray()
|
12 |
+
{
|
13 |
+
return array(
|
14 |
+
array('value' => 'gigya', 'label'=>Mage::helper('adminhtml')->__('Gigya (best practice)')),
|
15 |
+
array('value' => 'magento', 'label'=>Mage::helper('adminhtml')->__('Magento')),
|
16 |
+
);
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
app/code/community/Gigya/Social/Model/Customer/Observer.php
CHANGED
@@ -6,27 +6,30 @@
|
|
6 |
*/
|
7 |
class Gigya_Social_Model_Customer_Observer
|
8 |
{
|
|
|
9 |
protected $userMod;
|
10 |
protected $helper;
|
11 |
-
|
12 |
|
13 |
function __construct()
|
14 |
{
|
15 |
$this->userMod = Mage::getStoreConfig('gigya_login/gigya_user_management/login_modes');
|
16 |
-
$this->
|
|
|
17 |
}
|
18 |
|
19 |
-
|
20 |
public function notify_registration($observer)
|
21 |
{
|
22 |
if ($this->userMod == 'social') {
|
23 |
$customer_data = $observer['customer']->getData();
|
24 |
-
$id
|
25 |
if (!empty($customer_data['gigyaUser'])) {
|
26 |
$this->helper->notifyRegistration($customer_data['gigyaUser']['UID'], $id);
|
27 |
} else {
|
28 |
$this->helper->notifyLogin($id, 'true');
|
29 |
-
Mage::getSingleton('customer/session')->setSuppressNoteLogin(
|
|
|
|
|
30 |
}
|
31 |
}
|
32 |
}
|
@@ -34,13 +37,15 @@ class Gigya_Social_Model_Customer_Observer
|
|
34 |
public function notify_delete($observer)
|
35 |
{
|
36 |
|
37 |
-
$helper
|
38 |
-
$this->userMod = Mage::getStoreConfig(
|
|
|
|
|
39 |
if ($this->userMod == 'social') {
|
40 |
$id = $observer->getEvent()->getCustomer()->getId();
|
41 |
$this->helper->deleteAccount($id);
|
42 |
} elseif ($this->userMod == 'raas') {
|
43 |
-
$cust
|
44 |
$gigyaUid = $cust->getData('gigya_uid');
|
45 |
if (!empty($gigyaUid)) {
|
46 |
$helper->utils->deleteAccountByGUID($gigyaUid);
|
@@ -51,21 +56,28 @@ class Gigya_Social_Model_Customer_Observer
|
|
51 |
public function notify_login($observer)
|
52 |
{
|
53 |
if ($this->userMod == 'social') {
|
54 |
-
Mage::log(
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
if (!empty($action)) {
|
60 |
if ($action === 'linkAccount' && !empty($gigya_uid)) {
|
61 |
$this->helper->notifyRegistration($gigya_uid, $id);
|
62 |
}
|
63 |
} else {
|
64 |
-
$magInfo
|
65 |
$userInfo = array(
|
66 |
'firstName' => $magInfo['firstname'],
|
67 |
-
'lastName'
|
68 |
-
'email'
|
69 |
);
|
70 |
$this->helper->notifyLogin($id, 'false', $userInfo);
|
71 |
}
|
@@ -86,14 +98,18 @@ class Gigya_Social_Model_Customer_Observer
|
|
86 |
$id = $observer->getEvent()->getCustomer()->getId();
|
87 |
Mage::getSingleton('core/session')->setData('logout', 'true');
|
88 |
$this->helper->notifyLogout($id);
|
89 |
-
} else
|
90 |
-
$
|
91 |
-
|
|
|
|
|
|
|
92 |
// add gigya_uid to observer
|
93 |
// make sure gigya_uid is saved to magento customer data, and pull it from magento customer
|
94 |
// make the logout happen from browser side
|
95 |
-
|
96 |
-
|
|
|
97 |
}
|
98 |
}
|
99 |
|
@@ -103,10 +119,12 @@ class Gigya_Social_Model_Customer_Observer
|
|
103 |
public function syncToGigya($observer)
|
104 |
{
|
105 |
if ("raas" == $this->userMod) {
|
106 |
-
$customer
|
107 |
$attributes = $customer->getData();
|
108 |
-
$uid
|
109 |
-
$updater
|
|
|
|
|
110 |
$updater->updateGigya();
|
111 |
}
|
112 |
}
|
@@ -118,39 +136,105 @@ class Gigya_Social_Model_Customer_Observer
|
|
118 |
{
|
119 |
if ("raas" == $this->userMod) {
|
120 |
/** @var Gigya_Social_Helper_FieldMapping_MagentoUpdater $updater */
|
121 |
-
$updater
|
122 |
$gigyaAccount = $updater->getGigyaAccount();
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
}
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
public function convertGenderToGigya($observer)
|
129 |
{
|
130 |
if ("raas" == $this->userMod) {
|
131 |
/** @var Gigya_Social_Helper_FieldMapping_GigyaUpdater $updater */
|
132 |
-
$updater
|
133 |
-
$cmsArray
|
134 |
-
$
|
|
|
|
|
|
|
135 |
$updater->setCmsArray($cmsArray);
|
136 |
}
|
137 |
}
|
138 |
|
139 |
-
public function
|
140 |
{
|
141 |
-
$
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
148 |
}
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
-
return null;
|
|
|
|
|
154 |
}
|
155 |
}
|
156 |
|
6 |
*/
|
7 |
class Gigya_Social_Model_Customer_Observer
|
8 |
{
|
9 |
+
|
10 |
protected $userMod;
|
11 |
protected $helper;
|
12 |
+
protected $lead;
|
13 |
|
14 |
function __construct()
|
15 |
{
|
16 |
$this->userMod = Mage::getStoreConfig('gigya_login/gigya_user_management/login_modes');
|
17 |
+
$this->lead = Mage::getStoreConfig('gigya_login/gigya_raas_conf/session_lead');
|
18 |
+
$this->helper = Mage::helper('Gigya_Social');
|
19 |
}
|
20 |
|
|
|
21 |
public function notify_registration($observer)
|
22 |
{
|
23 |
if ($this->userMod == 'social') {
|
24 |
$customer_data = $observer['customer']->getData();
|
25 |
+
$id = $customer_data['entity_id'];
|
26 |
if (!empty($customer_data['gigyaUser'])) {
|
27 |
$this->helper->notifyRegistration($customer_data['gigyaUser']['UID'], $id);
|
28 |
} else {
|
29 |
$this->helper->notifyLogin($id, 'true');
|
30 |
+
Mage::getSingleton('customer/session')->setSuppressNoteLogin(
|
31 |
+
true
|
32 |
+
);
|
33 |
}
|
34 |
}
|
35 |
}
|
37 |
public function notify_delete($observer)
|
38 |
{
|
39 |
|
40 |
+
$helper = Mage::helper('Gigya_Social');
|
41 |
+
$this->userMod = Mage::getStoreConfig(
|
42 |
+
'gigya_login/gigya_user_management/login_modes'
|
43 |
+
);
|
44 |
if ($this->userMod == 'social') {
|
45 |
$id = $observer->getEvent()->getCustomer()->getId();
|
46 |
$this->helper->deleteAccount($id);
|
47 |
} elseif ($this->userMod == 'raas') {
|
48 |
+
$cust = $observer->getEvent()->getCustomer();
|
49 |
$gigyaUid = $cust->getData('gigya_uid');
|
50 |
if (!empty($gigyaUid)) {
|
51 |
$helper->utils->deleteAccountByGUID($gigyaUid);
|
56 |
public function notify_login($observer)
|
57 |
{
|
58 |
if ($this->userMod == 'social') {
|
59 |
+
Mage::log(
|
60 |
+
Mage::getSingleton('customer/session')->getSuppressNoteLogin()
|
61 |
+
);
|
62 |
+
if (!Mage::getSingleton('customer/session')->getSuppressNoteLogin()
|
63 |
+
) {
|
64 |
+
$action = Mage::getSingleton('customer/session')->getData(
|
65 |
+
'gigyaAction'
|
66 |
+
);
|
67 |
+
$id = $observer->getEvent()->getCustomer()->getId();
|
68 |
+
$gigya_uid = Mage::getSingleton('customer/session')->getData(
|
69 |
+
'gigyaUid'
|
70 |
+
);
|
71 |
if (!empty($action)) {
|
72 |
if ($action === 'linkAccount' && !empty($gigya_uid)) {
|
73 |
$this->helper->notifyRegistration($gigya_uid, $id);
|
74 |
}
|
75 |
} else {
|
76 |
+
$magInfo = $observer->getEvent()->getCustomer()->getData();
|
77 |
$userInfo = array(
|
78 |
'firstName' => $magInfo['firstname'],
|
79 |
+
'lastName' => $magInfo['lastname'],
|
80 |
+
'email' => $magInfo['email'],
|
81 |
);
|
82 |
$this->helper->notifyLogin($id, 'false', $userInfo);
|
83 |
}
|
98 |
$id = $observer->getEvent()->getCustomer()->getId();
|
99 |
Mage::getSingleton('core/session')->setData('logout', 'true');
|
100 |
$this->helper->notifyLogout($id);
|
101 |
+
} else {
|
102 |
+
if ($this->userMod == 'raas') {
|
103 |
+
$id = $observer->getEvent()->getCustomer()->getData(
|
104 |
+
'gigya_uid'
|
105 |
+
);
|
106 |
+
// gigya_uid does not get passed in in observer. options:
|
107 |
// add gigya_uid to observer
|
108 |
// make sure gigya_uid is saved to magento customer data, and pull it from magento customer
|
109 |
// make the logout happen from browser side
|
110 |
+
$params = array('UID' => $id);
|
111 |
+
$this->helper->utils->call('accounts.logout', $params);
|
112 |
+
}
|
113 |
}
|
114 |
}
|
115 |
|
119 |
public function syncToGigya($observer)
|
120 |
{
|
121 |
if ("raas" == $this->userMod) {
|
122 |
+
$customer = $observer->getEvent()->getCustomer();
|
123 |
$attributes = $customer->getData();
|
124 |
+
$uid = $attributes['gigya_uid'];
|
125 |
+
$updater = new Gigya_Social_Helper_FieldMapping_GigyaUpdater(
|
126 |
+
$attributes, $uid
|
127 |
+
);
|
128 |
$updater->updateGigya();
|
129 |
}
|
130 |
}
|
136 |
{
|
137 |
if ("raas" == $this->userMod) {
|
138 |
/** @var Gigya_Social_Helper_FieldMapping_MagentoUpdater $updater */
|
139 |
+
$updater = $observer->getData("updater");
|
140 |
$gigyaAccount = $updater->getGigyaAccount();
|
141 |
+
if (isset($gigyaAccount['profile']['gender'])) {
|
142 |
+
$gen = $this->genderConvert(
|
143 |
+
"g2cms", null, $gigyaAccount['profile']['gender']
|
144 |
+
);
|
145 |
+
$gigyaAccount['profile']['gender'] = null == $gen ? 0 : $gen;
|
146 |
+
$updater->setGigyaAccount($gigyaAccount);
|
147 |
+
}
|
148 |
}
|
149 |
}
|
150 |
+
|
151 |
+
public function genderConvert($direction, $cmsVal, $gigyaVal)
|
152 |
+
{
|
153 |
+
if (Mage::getEdition() == Mage::EDITION_ENTERPRISE) {
|
154 |
+
$mapping = array(
|
155 |
+
"m" => 123,
|
156 |
+
"f" => 124,
|
157 |
+
"u" => 0
|
158 |
+
);
|
159 |
+
} elseif (Mage::getEdition() == Mage::EDITION_COMMUNITY) {
|
160 |
+
$mapping = array(
|
161 |
+
"m" => 1,
|
162 |
+
"f" => 2,
|
163 |
+
"u" => 0
|
164 |
+
);
|
165 |
+
}
|
166 |
+
if ("g2cms" == $direction) {
|
167 |
+
return isset($mapping[$gigyaVal]) ? $mapping[$gigyaVal] : null;
|
168 |
+
}
|
169 |
+
if ("cms2g" == $direction) {
|
170 |
+
$fliped = array_flip($mapping);
|
171 |
+
return isset($fliped[$cmsVal]) ? $fliped[$cmsVal] : null;
|
172 |
+
}
|
173 |
+
return null;
|
174 |
+
}
|
175 |
+
|
176 |
public function convertGenderToGigya($observer)
|
177 |
{
|
178 |
if ("raas" == $this->userMod) {
|
179 |
/** @var Gigya_Social_Helper_FieldMapping_GigyaUpdater $updater */
|
180 |
+
$updater = $observer->getData("updater");
|
181 |
+
$cmsArray = $updater->getCmsArray();
|
182 |
+
$gen = $this->genderConvert(
|
183 |
+
"cms2g", $cmsArray['gender'], null
|
184 |
+
);
|
185 |
+
$cmsArray['gender'] = null == $gen ? 'u' : $gen;
|
186 |
$updater->setCmsArray($cmsArray);
|
187 |
}
|
188 |
}
|
189 |
|
190 |
+
public function reLoginToGigya($observer)
|
191 |
{
|
192 |
+
if ("raas" == $this->userMod && 'magento' == $this->lead) {
|
193 |
+
/** @var Mage_Customer_Model_Session $session */
|
194 |
+
$session = $observer->getData('customer_session');
|
195 |
+
if($session->isLoggedIn() && !$this->isGigyaLoggedIn()) {
|
196 |
+
/** @var Mage_Customer_Model_Customer $customer */
|
197 |
+
$customer = $session->getCustomer();
|
198 |
+
$gigyaUid = $customer->getData('gigya_uid');
|
199 |
+
Mage::log("Re-login to gigya", Zend_Log::INFO);
|
200 |
+
$this->doReLoginToGigya($gigyaUid);
|
201 |
+
}
|
202 |
}
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
private function isGigyaLoggedIn()
|
207 |
+
{
|
208 |
+
$apiKey = Mage::getStoreConfig('gigya_global/gigya_global_conf/apikey');
|
209 |
+
return isset($_COOKIE['glt_' . $apiKey]);
|
210 |
+
}
|
211 |
+
|
212 |
+
private function doReLoginToGigya($uid)
|
213 |
+
{
|
214 |
+
$expTime = $this->getExpirationTime();
|
215 |
+
return $this->helper->accountsNotifyLogin($uid, $expTime, 'cms relogin');
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
private function getExpirationTime()
|
220 |
+
{
|
221 |
+
$sessionExpiration = null;
|
222 |
+
$advanced_config = Mage::getStoreConfig('gigya_global/gigya_global_conf/advancedConfig');
|
223 |
+
if($advanced_config !== '') {
|
224 |
+
$advanced_config_arr = Mage::helper('Gigya_Social')->getGigGlobalAdvancedConfig($advanced_config);
|
225 |
+
if(!$advanced_config_arr) {
|
226 |
+
$advanced_config_arr = Mage::helper('Gigya_Social')->_confStringToArry($advanced_config);
|
227 |
+
}
|
228 |
+
if(!empty($advanced_config_arr['sessionExpiration'])) {
|
229 |
+
$sessionExpiration = $advanced_config_arr['sessionExpiration'];
|
230 |
+
} else {
|
231 |
+
}
|
232 |
+
} else {
|
233 |
+
$sessionExpiration = Mage::getStoreConfig(Mage_Core_Model_Cookie::XML_PATH_COOKIE_LIFETIME);
|
234 |
}
|
235 |
+
return (null == $sessionExpiration) ? 0 : $sessionExpiration;
|
236 |
+
|
237 |
+
|
238 |
}
|
239 |
}
|
240 |
|
app/code/community/Gigya/Social/controllers/LoginController.php
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
<?php
|
2 |
if (defined('COMPILER_INCLUDE_PATH')) {
|
3 |
-
|
4 |
-
}
|
5 |
-
|
|
|
6 |
}
|
7 |
|
8 |
require_once('Mage/Customer/controllers/AccountController.php');
|
@@ -12,676 +13,709 @@ require_once('Mage/Customer/controllers/AccountController.php');
|
|
12 |
*
|
13 |
* @author
|
14 |
*/
|
15 |
-
class Gigya_Social_LoginController extends Mage_Customer_AccountController
|
16 |
-
{
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
// a brute-force protection here would be nice
|
36 |
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
$action = $this->getRequest()->getActionName();
|
44 |
-
$openActions = array(
|
45 |
-
'create',
|
46 |
-
'login',
|
47 |
-
'logout',
|
48 |
-
'loginPost',
|
49 |
-
'logoutsuccess',
|
50 |
-
'forgotpassword',
|
51 |
-
'forgotpasswordpost',
|
52 |
-
'resetpassword',
|
53 |
-
'resetpasswordpost',
|
54 |
-
'confirm',
|
55 |
-
'confirmation'
|
56 |
-
);
|
57 |
-
$pattern = '/^(' . implode('|', $openActions) . ')/i';
|
58 |
-
|
59 |
-
if ( ! preg_match($pattern, $action)) {
|
60 |
-
if ( ! $this->_getSession()->authenticate($this)) {
|
61 |
-
$this->setFlag('', 'no-dispatch', true);
|
62 |
-
}
|
63 |
-
} else {
|
64 |
-
$this->_getSession()->setNoReferer(true);
|
65 |
-
}
|
66 |
}
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
$cust
|
123 |
-
= $this->_customerExists($email); // if customer exists in Magento receive obj, else false
|
124 |
-
// customer email exists login flow
|
125 |
-
if ($cust != false) {
|
126 |
-
// create event hook
|
127 |
-
Mage::dispatchEvent('gigya_raas_pre_login', array(
|
128 |
-
'customer' => $cust,
|
129 |
-
'gigyaData' => $this->gigyaData
|
130 |
-
));
|
131 |
-
$cust->firstname = $accountInfo['profile']['firstName'];
|
132 |
-
$cust->lastname = $accountInfo['profile']['lastName'];
|
133 |
-
$cust->save(); // save customer details in magento
|
134 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaData);
|
135 |
-
if ($updater->isMapped()) {
|
136 |
-
$updater->updateMagentoAccount($cust);
|
137 |
-
}
|
138 |
-
$cust_session->setCustomerAsLoggedIn($cust);
|
139 |
-
Mage::dispatchEvent('gigya_raas_post_login', array(
|
140 |
-
'customer_session' => $cust_session,
|
141 |
-
'gigyaData' => $this->gigyaData
|
142 |
-
));
|
143 |
-
$url = Mage::getUrl('*/*/*',
|
144 |
-
array('_current' => true)); // url for reload after creating logged in user
|
145 |
-
$cust_session->setData('gigyaAccount',
|
146 |
-
$accountInfo); // add all gigya accountinfo to customer session
|
147 |
-
$res = array(
|
148 |
-
'result' => 'login',
|
149 |
-
'redirect' => $url
|
150 |
-
);
|
151 |
-
$this->getResponse()->setBody(Mage::helper('core')
|
152 |
-
->jsonEncode($res)); // js will create the redirect after login
|
153 |
-
} else {
|
154 |
-
// create a user in magento
|
155 |
-
$firstName = $accountInfo['profile']['firstName'] ? $accountInfo['profile']['firstName']
|
156 |
-
: $accountInfo['profile']['nickname'];
|
157 |
-
$lastName = $accountInfo['profile']['lastName'] ? $accountInfo['profile']['lastName']
|
158 |
-
: $accountInfo['profile']['nickname'];
|
159 |
-
$this->_createCustomer($email, $firstName, $lastName, $accountInfo);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
} else {
|
163 |
-
$res = array(
|
164 |
-
'result' => 'error',
|
165 |
-
"errorMessage" => "User not valid"
|
166 |
-
);
|
167 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res)); // js will create the redirect after login
|
168 |
}
|
|
|
169 |
}
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
{
|
178 |
-
$accountInfo = $this->helper->utils->getAccount($uid); // (utils is set to GigyaCMS.php)
|
179 |
-
// getAccount in gigyaCMS is calling call().
|
180 |
-
// if call fails, it Checks if retry flag is set, if not, Retry once and set one retry flag.
|
181 |
-
// if it fails it returns error
|
182 |
-
if (is_numeric($accountInfo)) {
|
183 |
-
// js should log out from gigya
|
184 |
-
$res = array(
|
185 |
-
'result' => 'message',
|
186 |
-
'message' => "Oops! Something went wrong during your login/registration process. Please try to login/register again."
|
187 |
-
);
|
188 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res)); // *js should log out from gigya
|
189 |
-
Mage::log('Could not retrieve site account infoError ' . __FILE__ . ' ' . __LINE__);
|
190 |
-
|
191 |
-
return false;
|
192 |
-
} else {
|
193 |
-
return $accountInfo;
|
194 |
-
}
|
195 |
}
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
// first and last name should be set to required by Gigya. if they are still missing, create placeholder for them
|
234 |
-
$firstName = $post['user']['firstName'];
|
235 |
-
$lastName = $post['user']['lastName'];
|
236 |
-
$email = $post['user']['email'];
|
237 |
-
|
238 |
-
$this->_createCustomer($email, $firstName, $lastName, $post['user']);
|
239 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
240 |
-
} else {
|
241 |
-
//email exists - link accounts
|
242 |
-
$this->_socialLinkAccounts($post['UID']);
|
243 |
-
}
|
244 |
-
}
|
245 |
}
|
246 |
-
|
247 |
-
|
248 |
-
* Create Link accounts form and return to ajax
|
249 |
-
*
|
250 |
-
* @param int $uid
|
251 |
-
*/
|
252 |
-
protected function _socialLinkAccounts($uid)
|
253 |
-
{
|
254 |
-
try {
|
255 |
-
//return login form
|
256 |
-
$block = $this->getLayout()->createBlock(
|
257 |
-
'Mage_Core_Block_Template',
|
258 |
-
'Loginform',
|
259 |
-
array('template' => 'gigya/form/mini.login.phtml')
|
260 |
-
);
|
261 |
-
$form = $block->renderView();
|
262 |
-
$res = array(
|
263 |
-
'result' => 'emailExsists',
|
264 |
-
'html' => $form,
|
265 |
-
'id' => Mage::helper('Gigya_Social')->getPluginContainerId('gigya_login/gigya_login_conf'),
|
266 |
-
'headline' => $this->__('Link Accounts'),
|
267 |
-
);
|
268 |
-
Mage::getSingleton('customer/session')->setData('gigyaAction', 'linkAccount');
|
269 |
-
Mage::getSingleton('customer/session')->setData('gigyaUid', $uid);
|
270 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
271 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
272 |
-
} catch (Exception $e) {
|
273 |
-
//TODO:add error handeling
|
274 |
-
Mage::log('Link accounts failed. exception details: ' . $e . __FILE__ . ' ' . __LINE__);
|
275 |
-
}
|
276 |
}
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
297 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
298 |
-
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
$res = array(
|
332 |
-
'result' => 'loginFailed',
|
333 |
-
'message' => 'Login to site did not succeed.'
|
334 |
-
);
|
335 |
-
Mage::log('Login to Magento failed (_doSocialLogin()). probably UID does not exists or DB connection problem '
|
336 |
-
. __FILE__ . ' ' . __LINE__);
|
337 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
338 |
-
}
|
339 |
-
|
340 |
}
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
}
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
*/
|
376 |
-
protected function _createCustomer($email, $firstName = null, $lastName = null, $gigyaUser)
|
377 |
-
{
|
378 |
-
$customer = Mage::getModel('customer/customer')->setId(null);
|
379 |
-
$customer->getGroupId();
|
380 |
-
$customer->setFirstname($firstName);
|
381 |
-
$customer->setLastname($lastName);
|
382 |
-
$customer->setEmail($email);
|
383 |
-
if ( ! empty($gigyaUser['missInfo'])) {
|
384 |
-
$missing_info = $gigyaUser['missInfo'];
|
385 |
-
if (array_key_exists('dob', $missing_info)) {
|
386 |
-
$this->buildDob($missing_info);
|
387 |
-
}
|
388 |
-
foreach ($missing_info as $key => $val) {
|
389 |
-
$k = 'set' . ucfirst($key);
|
390 |
-
$customer->{$k}($val);
|
391 |
-
}
|
392 |
-
}
|
393 |
-
$password = Mage::helper('Gigya_Social')->_getPassword();
|
394 |
-
$_POST['password'] = $password;
|
395 |
-
$_POST['confirmation'] = $password;
|
396 |
-
$_POST['passwordConfirmation'] = $password; // since Magento 1.9.1.0 field is called passwordConfirmation.
|
397 |
-
if ($this->userMode == 'social') {
|
398 |
-
$customer->setData('gigyaUser', $gigyaUser);
|
399 |
-
} else {
|
400 |
-
if ($this->userMode == 'raas') {
|
401 |
-
$cust_session = Mage::getSingleton('customer/session');
|
402 |
-
$cust_session->setData('gigyaAccount', $gigyaUser);
|
403 |
-
$customer->setData('gigya_uid', $gigyaUser['UID']);
|
404 |
-
}
|
405 |
-
}
|
406 |
-
Mage::register('current_customer', $customer); // throws core exception
|
407 |
-
$this->_forward('createPost', null, null, array('gigyaData' => $gigyaUser));
|
408 |
-
// forward is magento way to call createPost function.
|
409 |
-
// createPost creates the actual registration by posting to magento and reloading.
|
410 |
}
|
411 |
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
|
418 |
-
|
419 |
-
|
420 |
-
*/
|
421 |
-
public function createPostAction()
|
422 |
-
{
|
423 |
-
$session = $this->_getSession();
|
424 |
-
if ($session->isLoggedIn()) {
|
425 |
-
Mage::log('loggedIn ' . __FILE__ . ' ' . __LINE__);
|
426 |
|
427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
}
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
$
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
$address = Mage::getModel('customer/address');
|
456 |
-
/* @var $addressForm Mage_Customer_Model_Form */
|
457 |
-
$addressForm = Mage::getModel('customer/form');
|
458 |
-
$addressForm->setFormCode('customer_register_address')
|
459 |
-
->setEntity($address);
|
460 |
-
|
461 |
-
$addressData = $addressForm->extractData($this->getRequest(), 'address', false);
|
462 |
-
$addressErrors = $addressForm->validateData($addressData);
|
463 |
-
if ($addressErrors === true) {
|
464 |
-
$address->setId(null)
|
465 |
-
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
|
466 |
-
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
|
467 |
-
$addressForm->compactData($addressData);
|
468 |
-
$customer->addAddress($address);
|
469 |
-
|
470 |
-
$addressErrors = $address->validate();
|
471 |
-
if (is_array($addressErrors)) {
|
472 |
-
$errors = array_merge($errors, $addressErrors);
|
473 |
-
}
|
474 |
-
} else {
|
475 |
-
$errors = array_merge($errors, $addressErrors);
|
476 |
-
}
|
477 |
}
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
if ($customerErrors !== true) {
|
482 |
-
$fields = $customerForm->getAttributes();
|
483 |
-
foreach ($fields as $field) {
|
484 |
-
$requireds[$field->getAttributeCode()] = $field->getIsRequired();
|
485 |
-
}
|
486 |
-
//remove fields that we have data for
|
487 |
-
unset($requireds['firstname'], $requireds['lastname'], $requireds['email']);
|
488 |
-
$requireds = array_filter($requireds);
|
489 |
-
$html = '<div class="gigyaMoreInfo"><form action="' . Mage::getBaseUrl()
|
490 |
-
. 'gigyalogin/login" name="moreInfo" id="gigyaMoreInfoForm">';
|
491 |
-
foreach ($requireds as $key => $r) {
|
492 |
-
$requireds[$key] = $fields[$key]->getStoreLabel();
|
493 |
-
if ( ! $fields[$key]->getIsUserDefined()
|
494 |
-
&& is_object($this->getLayout()->createBlock('customer/widget_' . $key))
|
495 |
-
) {
|
496 |
-
$html .= $this->getLayout()->createBlock('customer/widget_' . $key)->toHtml();
|
497 |
-
} else {
|
498 |
-
$html
|
499 |
-
.= '<div class="field">
|
500 |
<label for="' . $key . '">' . $fields[$key]->getStoreLabel() . '</label>
|
501 |
<div class="input-box">
|
502 |
<input type="text" name="' . $key . '" id="' . $key . '" value="" class="input-text" />
|
503 |
</div>
|
504 |
</div>';
|
505 |
-
}
|
506 |
-
}
|
507 |
-
$html .= '<input class="button" id="gigyaMoreInfoSubmit" type="button" value="Send" onclick="gigyaFunctions.moreInfoSubmit()" "></form>';
|
508 |
-
$html .= '</div>';
|
509 |
-
|
510 |
-
$res = array(
|
511 |
-
'result' => 'moreInfo',
|
512 |
-
'fields' => $requireds,
|
513 |
-
'html' => $html,
|
514 |
-
);
|
515 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
516 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
517 |
-
|
518 |
-
return;
|
519 |
-
} else {
|
520 |
-
$customerForm->compactData($customerData);
|
521 |
-
$customer->setPassword($this->getRequest()->getPost('password'));
|
522 |
-
$customer->setConfirmation($this->getRequest()->getPost('confirmation'));
|
523 |
-
$customer->setPasswordConfirmation($this->getRequest()->getPost('confirmation'));
|
524 |
-
$customerErrors = $customer->validate();
|
525 |
-
if (is_array($customerErrors)) {
|
526 |
-
$errors = array_merge($customerErrors, $errors);
|
527 |
-
}
|
528 |
-
}
|
529 |
-
|
530 |
-
$validationResult = count($errors) == 0;
|
531 |
-
|
532 |
-
if (true === $validationResult) {
|
533 |
-
$params = $this->getRequest()->getParams();
|
534 |
-
Mage::dispatchEvent('gigya_pre_user_create', array(
|
535 |
-
'customer' => $customer,
|
536 |
-
'gigya_data' => $params['gigyaData']
|
537 |
-
));
|
538 |
-
$customer->save();
|
539 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($params['gigyaData']);
|
540 |
-
if ($updater->isMapped()) {
|
541 |
-
$updater->updateMagentoAccount($customer);
|
542 |
-
}
|
543 |
-
Mage::dispatchEvent('customer_register_success',
|
544 |
-
array('account_controller' => $this, 'customer' => $customer)
|
545 |
-
);
|
546 |
-
|
547 |
-
if ($customer->isConfirmationRequired()) {
|
548 |
-
$customer->sendNewAccountEmail(
|
549 |
-
'confirmation',
|
550 |
-
$session->getBeforeAuthUrl(),
|
551 |
-
Mage::app()->getStore()->getId()
|
552 |
-
);
|
553 |
-
$session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.',
|
554 |
-
Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
|
555 |
-
|
556 |
-
return;
|
557 |
-
} else {
|
558 |
-
$session->setCustomerAsLoggedIn($customer);
|
559 |
-
$url = $this->_welcomeCustomer($customer);
|
560 |
-
//$url = Mage::getUrl('customer/account');
|
561 |
-
//$this->_redirectSuccess($url);
|
562 |
-
$res = array(
|
563 |
-
'result' => 'newUser',
|
564 |
-
'redirect' => $url
|
565 |
-
);
|
566 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
567 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
568 |
-
}
|
569 |
-
} else {
|
570 |
-
Mage::log($errors . __FILE__ . ' ' . __LINE__);
|
571 |
-
$session->setCustomerFormData($this->getRequest()->getPost());
|
572 |
-
$error = '';
|
573 |
-
if (is_array($errors)) {
|
574 |
-
foreach ($errors as $errorMessage) {
|
575 |
-
$session->addError($errorMessage);
|
576 |
-
$error .= $errorMessage . "\n";
|
577 |
-
}
|
578 |
-
$res['result'] = 'error';
|
579 |
-
$res['message'] = $error;
|
580 |
-
} else {
|
581 |
-
$res['result'] = 'error';
|
582 |
-
$res['message'] = $this->__('Invalid customer data');
|
583 |
-
}
|
584 |
-
}
|
585 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
586 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
587 |
-
} catch (Mage_Core_Exception $e) {
|
588 |
-
$session->setCustomerFormData($this->getRequest()->getPost());
|
589 |
-
if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
|
590 |
-
$message = $this->__('There is already an account with this email address.');
|
591 |
-
} else {
|
592 |
-
$message = $e->getMessage();
|
593 |
-
}
|
594 |
-
$res['result'] = 'error';
|
595 |
-
$res['message'] = $message;
|
596 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
597 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
598 |
-
} catch (Exception $e) {
|
599 |
-
$session->setCustomerFormData($this->getRequest()->getPost())
|
600 |
-
->addException($e, $this->__('Cannot save the customer.'));
|
601 |
-
$message = $this->__('Cannot save the customer.');
|
602 |
-
$res['result'] = 'error';
|
603 |
-
$res['message'] = $message;
|
604 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
605 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
606 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
}
|
608 |
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
$
|
621 |
-
|
622 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
|
624 |
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
}
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
if ($session->getCustomer()->getIsJustConfirmed()) {
|
635 |
-
$this->_welcomeCustomer($session->getCustomer(), true);
|
636 |
-
}
|
637 |
-
$res['result'] = 'success';
|
638 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
639 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
640 |
-
} catch (Mage_Core_Exception $e) {
|
641 |
-
switch ($e->getCode()) {
|
642 |
-
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
|
643 |
-
$value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
|
644 |
-
$message = Mage::helper('customer')
|
645 |
-
->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.',
|
646 |
-
$value);
|
647 |
-
break;
|
648 |
-
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
|
649 |
-
$message = $e->getMessage();
|
650 |
-
break;
|
651 |
-
default:
|
652 |
-
$message = $e->getMessage();
|
653 |
-
}
|
654 |
-
$res['result'] = 'error';
|
655 |
-
$res['message'] = $message;
|
656 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
657 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
658 |
-
} catch (Exception $e) {
|
659 |
-
// Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
|
660 |
-
}
|
661 |
-
} else {
|
662 |
-
$res['result'] = 'error';
|
663 |
-
$res['message'] = $this->__('Login and password are required.');
|
664 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
665 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
666 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
667 |
}
|
668 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
669 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
670 |
}
|
671 |
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
681 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
682 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
683 |
-
|
684 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
685 |
|
686 |
}
|
687 |
|
1 |
<?php
|
2 |
if (defined('COMPILER_INCLUDE_PATH')) {
|
3 |
+
include_once 'Gigya_Social_sdk_GSSDK.php';
|
4 |
+
}
|
5 |
+
else {
|
6 |
+
include_once __DIR__ . '/../sdk/GSSDK.php';
|
7 |
}
|
8 |
|
9 |
require_once('Mage/Customer/controllers/AccountController.php');
|
13 |
*
|
14 |
* @author
|
15 |
*/
|
16 |
+
class Gigya_Social_LoginController extends Mage_Customer_AccountController {
|
|
|
17 |
|
18 |
+
private $helper;
|
19 |
+
private $userMode;
|
20 |
+
private $gigyaData;
|
21 |
|
22 |
+
public function indexAction() {
|
23 |
+
$this->loadLayout();
|
24 |
+
$this->renderLayout();
|
25 |
+
}
|
|
|
26 |
|
27 |
+
/**
|
28 |
+
* Action predispatch
|
29 |
+
*
|
30 |
+
* Check customer authentication for some actions
|
31 |
+
*/
|
32 |
+
public function preDispatch() {
|
33 |
+
// a brute-force protection here would be nice
|
|
|
34 |
|
35 |
+
parent::preDispatch();
|
36 |
|
37 |
+
if (!$this->getRequest()->isDispatched()) {
|
38 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
+
$action = $this->getRequest()->getActionName();
|
42 |
+
$openActions = array(
|
43 |
+
'create',
|
44 |
+
'login',
|
45 |
+
'logout',
|
46 |
+
'loginPost',
|
47 |
+
'logoutsuccess',
|
48 |
+
'forgotpassword',
|
49 |
+
'forgotpasswordpost',
|
50 |
+
'resetpassword',
|
51 |
+
'resetpasswordpost',
|
52 |
+
'confirm',
|
53 |
+
'confirmation'
|
54 |
+
);
|
55 |
+
$pattern = '/^(' . implode('|', $openActions) . ')/i';
|
56 |
+
|
57 |
+
if (!preg_match($pattern, $action)) {
|
58 |
+
if (!$this->_getSession()->authenticate($this)) {
|
59 |
+
$this->setFlag('', 'no-dispatch', TRUE);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
else {
|
63 |
+
$this->_getSession()->setNoReferer(TRUE);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/*
|
68 |
+
* Login Gateway
|
69 |
+
* Check which login mode is enabled
|
70 |
+
* activate social Login or Raas accordingly
|
71 |
+
*/
|
72 |
+
public function loginAction() {
|
73 |
+
$this->helper = Mage::helper("Gigya_Social");
|
74 |
+
$this->userMode = Mage::getStoreConfig('gigya_login/gigya_user_management/login_modes');
|
75 |
+
$session = $this->_getSession();
|
76 |
+
$req = $this->getRequest()->getPost('json');
|
77 |
+
$post = json_decode($req, TRUE);
|
78 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
79 |
+
|
80 |
+
if (!empty($post)) {
|
81 |
+
if ($this->userMode === 'social') {
|
82 |
+
$this->_socialLoginRegister($session, $post);
|
83 |
+
$this->gigyaData = $post;
|
84 |
+
}
|
85 |
+
elseif ($this->userMode === 'raas') {
|
86 |
+
$this->_raasLoginRegister($session, $post);
|
87 |
+
}
|
88 |
+
else {
|
89 |
+
$this->_getSession()->addError($this->__('Gigya login is disabled'));
|
90 |
+
}
|
91 |
+
}
|
92 |
+
else {
|
93 |
+
Mage::log('No data arrived in post ' . __FILE__ . ' ' . __LINE__);
|
94 |
}
|
95 |
|
96 |
+
}
|
97 |
+
|
98 |
+
/*
|
99 |
+
* Handle Raas login process:
|
100 |
+
* at any stage if an error occurs and login/registration fails, create js response message and skip to func end
|
101 |
+
* test UID sig validation
|
102 |
+
* validate user authenticity
|
103 |
+
* get account info from gigya
|
104 |
+
* check if account exists in magento
|
105 |
+
* if not create account, create login and reload
|
106 |
+
* if yes create login and reload
|
107 |
+
*/
|
108 |
+
protected function _raasLoginRegister($session, $post) {
|
109 |
+
$valid = FALSE;
|
110 |
+
if (isset($post['UIDSignature'])) {
|
111 |
+
$valid = Mage::helper('Gigya_Social')
|
112 |
+
->validateGigyaUid($post['UID'], $post['UIDSignature'],
|
113 |
+
$post['signatureTimestamp']);
|
114 |
+
}
|
115 |
+
else {
|
116 |
+
Mage::log('Gigya UIDSignature missing ' . __FILE__ . ' ' . __LINE__);
|
117 |
+
}
|
118 |
+
////
|
119 |
+
if ($valid) {
|
120 |
+
$accountInfo = $this->_raasAccountInfo($post['UID']); // account info from gigya
|
121 |
+
if ($accountInfo) { // if $accountInfo is false skip this and continue with response to ajax
|
122 |
+
$this->gigyaData = $accountInfo;
|
123 |
+
$cust_session = Mage::getSingleton('customer/session');
|
124 |
+
$email = $this->gigyaData['profile']['email'];
|
125 |
+
$cust
|
126 |
+
= $this->_customerExists($email); // if customer exists in Magento receive obj, else false
|
127 |
+
// customer email exists login flow
|
128 |
+
if ($cust != FALSE) {
|
129 |
+
// create event hook
|
130 |
+
Mage::dispatchEvent('gigya_raas_pre_login', array(
|
131 |
+
'customer' => $cust,
|
132 |
+
'gigyaData' => $this->gigyaData
|
133 |
+
));
|
134 |
+
$cust->firstname = $accountInfo['profile']['firstName'];
|
135 |
+
$cust->lastname = $accountInfo['profile']['lastName'];
|
136 |
+
$cust->save(); // save customer details in magento
|
137 |
+
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaData);
|
138 |
+
if ($updater->isMapped()) {
|
139 |
+
$updater->updateMagentoAccount($cust);
|
140 |
+
}
|
141 |
+
$cust_session->setCustomerAsLoggedIn($cust);
|
142 |
+
Mage::dispatchEvent('gigya_raas_post_login', array(
|
143 |
+
'customer_session' => $cust_session,
|
144 |
+
'gigyaData' => $this->gigyaData
|
145 |
+
));
|
146 |
+
$url = Mage::getUrl('*/*/*',
|
147 |
+
array('_current' => TRUE)); // url for reload after creating logged in user
|
148 |
+
$cust_session->setData('gigyaAccount',
|
149 |
+
$accountInfo); // add all gigya accountinfo to customer session
|
150 |
+
$res = array(
|
151 |
+
'result' => 'login',
|
152 |
+
'redirect' => $url
|
153 |
+
);
|
154 |
+
$this->getResponse()->setBody(Mage::helper('core')
|
155 |
+
->jsonEncode($res)); // js will create the redirect after login
|
156 |
}
|
157 |
+
else {
|
158 |
+
// create a user in magento
|
159 |
+
$firstName = $accountInfo['profile']['firstName'] ? $accountInfo['profile']['firstName']
|
160 |
+
: $accountInfo['profile']['nickname'];
|
161 |
+
$lastName = $accountInfo['profile']['lastName'] ? $accountInfo['profile']['lastName']
|
162 |
+
: $accountInfo['profile']['nickname'];
|
163 |
+
$this->_createCustomer($email, $firstName, $lastName, $accountInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
}
|
165 |
+
}
|
166 |
}
|
167 |
+
else {
|
168 |
+
$res = array(
|
169 |
+
'result' => 'error',
|
170 |
+
"errorMessage" => "User not valid"
|
171 |
+
);
|
172 |
+
$this->getResponse()->setBody(Mage::helper('core')
|
173 |
+
->jsonEncode($res)); // js will create the redirect after login
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
+
}
|
176 |
+
|
177 |
+
/*
|
178 |
+
* get Raas account info from gigya server
|
179 |
+
* @param int id
|
180 |
+
* $return mixed obj/false $accountInfo
|
181 |
+
*/
|
182 |
+
protected function _raasAccountInfo($uid) {
|
183 |
+
$accountInfo = $this->helper->utils->getAccount($uid); // (utils is set to GigyaCMS.php)
|
184 |
+
// getAccount in gigyaCMS is calling call().
|
185 |
+
// if call fails, it Checks if retry flag is set, if not, Retry once and set one retry flag.
|
186 |
+
// if it fails it returns error
|
187 |
+
if (is_numeric($accountInfo)) {
|
188 |
+
// js should log out from gigya
|
189 |
+
$res = array(
|
190 |
+
'result' => 'message',
|
191 |
+
'message' => "Oops! Something went wrong during your login/registration process. Please try to login/register again."
|
192 |
+
);
|
193 |
+
$this->getResponse()->setBody(Mage::helper('core')
|
194 |
+
->jsonEncode($res)); // *js should log out from gigya
|
195 |
+
Mage::log('Could not retrieve site account infoError ' . __FILE__ . ' ' . __LINE__);
|
196 |
+
|
197 |
+
return FALSE;
|
198 |
}
|
199 |
+
return $accountInfo;
|
200 |
+
}
|
201 |
+
|
202 |
+
protected function _socialLoginRegister($session, $post) {
|
203 |
+
// validate user signature authenticity
|
204 |
+
$valid = Mage::helper('Gigya_Social')
|
205 |
+
->validateGigyaUid($post['UID'], $post['UIDSignature'],
|
206 |
+
$post['signatureTimestamp']);
|
207 |
+
if ($valid == TRUE) {
|
208 |
+
// check if user exists in magento
|
209 |
+
// social is using 'UID' as common id with magento (while raas is using email)
|
210 |
+
// (on first Gigya reg. Gigya creates temp UID. after site registration, the UID in gigya is updated to site UID and isSiteUID is set to true)
|
211 |
+
if ($post['isSiteUID'] && is_numeric($post['UID'])) {
|
212 |
+
$this->_doSocialLogin($post);
|
213 |
+
}
|
214 |
+
else { // no siteID.
|
215 |
+
$this->_doSocialRegistration($post);
|
216 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
}
|
218 |
+
else {
|
219 |
+
Mage::log('User sig not valid ' . __FILE__ . ' ' . __LINE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
+
}
|
222 |
+
|
223 |
+
/*
|
224 |
+
* Register Gigya user as new site user (Gigya user does not exist in Magento).
|
225 |
+
* 2 options: email exists (in post) or not.
|
226 |
+
* no email (e.g Twitter user) - flow to create form to get missing email and resubmit process -
|
227 |
+
* (can be moved to FE JS)
|
228 |
+
*
|
229 |
+
* @param array $post
|
230 |
+
* $return bool $registered
|
231 |
+
*/
|
232 |
+
protected function _doSocialRegistration($post) {
|
233 |
+
if (empty($post['user']['email'])) {
|
234 |
+
$this->_socialEmailForm(); // create email form and return to FE Ajax
|
235 |
+
}
|
236 |
+
else {
|
237 |
+
$customer = $this->_customerExists($post['user']['email']);
|
238 |
+
if ($customer === FALSE) {
|
239 |
+
// create new customer
|
240 |
+
// first and last name should be set to required by Gigya. if they are still missing, create placeholder for them
|
241 |
+
$firstName = $post['user']['firstName'];
|
242 |
+
$lastName = $post['user']['lastName'];
|
243 |
+
$email = $post['user']['email'];
|
244 |
+
|
245 |
+
$this->_createCustomer($email, $firstName, $lastName, $post['user']);
|
246 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
247 |
+
}
|
248 |
+
else {
|
249 |
+
//email exists - link accounts
|
250 |
+
$this->_socialLinkAccounts($post['UID']);
|
251 |
+
}
|
252 |
}
|
253 |
+
}
|
254 |
+
|
255 |
+
/*
|
256 |
+
* Create Link accounts form and return to ajax
|
257 |
+
*
|
258 |
+
* @param int $uid
|
259 |
+
*/
|
260 |
+
protected function _socialLinkAccounts($uid) {
|
261 |
+
try {
|
262 |
+
//return login form
|
263 |
+
$block = $this->getLayout()->createBlock(
|
264 |
+
'Mage_Core_Block_Template',
|
265 |
+
'Loginform',
|
266 |
+
array('template' => 'gigya/form/mini.login.phtml')
|
267 |
+
);
|
268 |
+
$form = $block->renderView();
|
269 |
+
$res = array(
|
270 |
+
'result' => 'emailExsists',
|
271 |
+
'html' => $form,
|
272 |
+
'id' => Mage::helper('Gigya_Social')
|
273 |
+
->getPluginContainerId('gigya_login/gigya_login_conf'),
|
274 |
+
'headline' => $this->__('Link Accounts'),
|
275 |
+
);
|
276 |
+
Mage::getSingleton('customer/session')
|
277 |
+
->setData('gigyaAction', 'linkAccount');
|
278 |
+
Mage::getSingleton('customer/session')->setData('gigyaUid', $uid);
|
279 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
280 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
281 |
+
} catch (Exception $e) {
|
282 |
+
//TODO:add error handeling
|
283 |
+
Mage::log('Link accounts failed. exception details: ' . $e . __FILE__ . ' ' . __LINE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}
|
285 |
+
}
|
286 |
+
|
287 |
+
/*
|
288 |
+
* Create missing email form and return to Ajax response
|
289 |
+
*/
|
290 |
+
protected function _socialEmailForm() {
|
291 |
+
$block = $this->getLayout()->createBlock(
|
292 |
+
'Mage_Core_Block_Template',
|
293 |
+
'Emailform',
|
294 |
+
array('template' => 'gigya/form/emailForm.phtml')
|
295 |
+
);
|
296 |
+
$form = $block->renderView();
|
297 |
+
$res = array(
|
298 |
+
'result' => 'noEmail',
|
299 |
+
'html' => $form,
|
300 |
+
'id' => Mage::helper('Gigya_Social')
|
301 |
+
->getPluginContainerId('gigya_login/gigya_login_conf'),
|
302 |
+
'headline' => $this->__('Fill-in missing required info'),
|
303 |
+
);
|
304 |
+
|
305 |
+
Mage::log('Gigya user Missing email field, created add email form. ' . __FILE__ . ' ' . __LINE__);
|
306 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
307 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
308 |
+
}
|
309 |
+
|
310 |
+
/*
|
311 |
+
* Login Gigya social user to magento
|
312 |
+
* @param array $post
|
313 |
+
* @return login result as Ajax result array
|
314 |
+
*/
|
315 |
+
protected function _doSocialLogin($post) {
|
316 |
+
|
317 |
+
$cust_session = Mage::getSingleton('customer/session');
|
318 |
+
$cust_session->setData('gigyaAction',
|
319 |
+
'login'); // add gigya login data to customer session
|
320 |
+
// the data will be used by observers set in model/customer/observer.php (and registered in config.php events). such as notify_login
|
321 |
+
Mage::dispatchEvent('gigya_social_pre_login', array(
|
322 |
+
'customer_session' => $cust_session,
|
323 |
+
'gigyaData' => $this->gigyaData
|
324 |
+
));
|
325 |
+
$login_success = $cust_session->loginById($post['user']['UID']); // log in gigya user to magento
|
326 |
+
if ($login_success) {
|
327 |
+
Mage::dispatchEvent('gigya_social_post_login', array(
|
328 |
+
'customer_session' => $cust_session,
|
329 |
+
'gigyaData' => $this->gigyaData
|
330 |
+
));
|
331 |
+
$cust_session->setData('gigyaAccount', $post);
|
332 |
+
//$url = Mage::getUrl('customer/account');
|
333 |
+
$url = Mage::getUrl('*/*/*', array('_current' => TRUE));
|
334 |
+
$res = array(
|
335 |
+
'result' => 'login',
|
336 |
+
'redirect' => $url
|
337 |
+
);
|
338 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
339 |
}
|
340 |
+
else {
|
341 |
+
$res = array(
|
342 |
+
'result' => 'loginFailed',
|
343 |
+
'message' => 'Login to site did not succeed.'
|
344 |
+
);
|
345 |
+
Mage::log('Login to Magento failed (_doSocialLogin()). probably UID does not exists or DB connection problem '
|
346 |
+
. __FILE__ . ' ' . __LINE__);
|
347 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
}
|
349 |
|
350 |
+
}
|
351 |
+
|
352 |
+
/*
|
353 |
+
* Check if customer exists in Magento
|
354 |
+
* @param string @email
|
355 |
+
*
|
356 |
+
* @return mixed $customer obj / False
|
357 |
+
*/
|
358 |
+
protected function _customerExists($email, $websiteId = NULL) {
|
359 |
+
$customer = Mage::getModel('customer/customer');
|
360 |
+
if ($websiteId) {
|
361 |
+
$customer->setWebsiteId($websiteId);
|
362 |
}
|
363 |
+
else {
|
364 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
365 |
+
}
|
366 |
+
$customer->loadByEmail($email);
|
367 |
+
if ($customer->getId()) {
|
368 |
+
return $customer;
|
369 |
+
}
|
370 |
+
else {
|
371 |
+
Mage::log('Customer could not be found in Magento DB using email from Gigya user. creating new user '
|
372 |
+
. __FILE__ . ' ' . __LINE__);
|
373 |
|
374 |
+
return FALSE;
|
375 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Create Magento customer with Gigya user details (Raas + Social)
|
381 |
+
*
|
382 |
+
* @param string $email
|
383 |
+
* @param string $firstName
|
384 |
+
* @param string $lastName
|
385 |
+
* @param obj $gigyaUser
|
386 |
+
*/
|
387 |
+
protected function _createCustomer(
|
388 |
+
$email,
|
389 |
+
$firstName = NULL,
|
390 |
+
$lastName = NULL,
|
391 |
+
$gigyaUser
|
392 |
+
) {
|
393 |
+
$customer = Mage::getModel('customer/customer')->setId(NULL);
|
394 |
+
$customer->getGroupId();
|
395 |
+
$customer->setFirstname($firstName);
|
396 |
+
$customer->setLastname($lastName);
|
397 |
+
$customer->setEmail($email);
|
398 |
+
if (!empty($gigyaUser['missInfo'])) {
|
399 |
+
$missing_info = $gigyaUser['missInfo'];
|
400 |
+
if (array_key_exists('dob', $missing_info)) {
|
401 |
+
$this->buildDob($missing_info);
|
402 |
+
}
|
403 |
+
foreach ($missing_info as $key => $val) {
|
404 |
+
$k = 'set' . ucfirst($key);
|
405 |
+
$customer->{$k}($val);
|
406 |
+
}
|
407 |
+
}
|
408 |
+
$password = Mage::helper('Gigya_Social')
|
409 |
+
->_getPassword();
|
410 |
+
$_POST['password'] = $password;
|
411 |
+
$_POST['confirmation'] = $password;
|
412 |
+
$_POST['passwordConfirmation'] = $password; // since Magento 1.9.1.0 field is called passwordConfirmation.
|
413 |
+
if ($this->userMode == 'social') {
|
414 |
+
$customer->setData('gigyaUser', $gigyaUser);
|
415 |
+
}
|
416 |
+
else {
|
417 |
+
if ($this->userMode == 'raas') {
|
418 |
+
$cust_session = Mage::getSingleton('customer/session');
|
419 |
+
$cust_session->setData('gigyaAccount', $gigyaUser);
|
420 |
+
$customer->setData('gigya_uid', $gigyaUser['UID']);
|
421 |
+
}
|
422 |
+
}
|
423 |
+
Mage::register('current_customer', $customer); // throws core exception
|
424 |
+
$this->_forward('createPost', NULL, NULL, array('gigyaData' => $gigyaUser));
|
425 |
+
// forward is magento way to call createPost function.
|
426 |
+
// createPost creates the actual registration by posting to magento and reloading.
|
427 |
+
}
|
428 |
+
|
429 |
+
private function buildDob(&$info) {
|
430 |
+
$info['dob'] = $info['year'] . "-" . $info['month'] . "-" . $info['day'];
|
431 |
+
unset($info['year'], $info['month'], $info['day']);
|
432 |
+
}
|
433 |
+
|
434 |
+
/*
|
435 |
+
* Copied magento action
|
436 |
+
*/
|
437 |
+
public function createPostAction() {
|
438 |
+
$session = $this->_getSession();
|
439 |
+
if ($session->isLoggedIn()) {
|
440 |
+
Mage::log('loggedIn ' . __FILE__ . ' ' . __LINE__);
|
441 |
+
|
442 |
+
return;
|
443 |
+
}
|
444 |
+
$session->setEscapeMessages(TRUE); // prevent XSS injection in user input
|
445 |
+
if ($this->getRequest()->isPost()) {
|
446 |
+
$errors = array();
|
447 |
+
|
448 |
+
if (!$customer = Mage::registry('current_customer')) {
|
449 |
+
$customer = Mage::getModel('customer/customer')->setId(NULL);
|
450 |
+
}
|
451 |
+
|
452 |
+
/* @var $customerForm Mage_Customer_Model_Form */
|
453 |
+
$customerForm = Mage::getModel('customer/form');
|
454 |
+
$customerForm->setFormCode('customer_account_create')
|
455 |
+
->setEntity($customer);
|
456 |
+
|
457 |
+
$customerData = $customerForm->extractData($this->getRequest());
|
458 |
+
|
459 |
+
if ($this->getRequest()->getParam('is_subscribed', FALSE)) {
|
460 |
+
$customer->setIsSubscribed(1);
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Initialize customer group id
|
465 |
+
*/
|
466 |
+
$customer->getGroupId();
|
467 |
+
|
468 |
+
if ($this->getRequest()->getPost('create_address')) {
|
469 |
+
/* @var $address Mage_Customer_Model_Address */
|
470 |
+
$address = Mage::getModel('customer/address');
|
471 |
+
/* @var $addressForm Mage_Customer_Model_Form */
|
472 |
+
$addressForm = Mage::getModel('customer/form');
|
473 |
+
$addressForm->setFormCode('customer_register_address')
|
474 |
+
->setEntity($address);
|
475 |
+
|
476 |
+
$addressData = $addressForm->extractData($this->getRequest(),
|
477 |
+
'address', FALSE);
|
478 |
+
$addressErrors = $addressForm->validateData($addressData);
|
479 |
+
if ($addressErrors === TRUE) {
|
480 |
+
$address->setId(NULL)
|
481 |
+
->setIsDefaultBilling($this->getRequest()
|
482 |
+
->getParam('default_billing', FALSE))
|
483 |
+
->setIsDefaultShipping($this->getRequest()
|
484 |
+
->getParam('default_shipping', FALSE));
|
485 |
+
$addressForm->compactData($addressData);
|
486 |
+
$customer->addAddress($address);
|
487 |
+
|
488 |
+
$addressErrors = $address->validate();
|
489 |
+
if (is_array($addressErrors)) {
|
490 |
+
$errors = array_merge($errors, $addressErrors);
|
491 |
+
}
|
492 |
}
|
493 |
+
else {
|
494 |
+
$errors = array_merge($errors, $addressErrors);
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
try {
|
499 |
+
$customerErrors = $customerForm->validateData($customerData);
|
500 |
+
if ($customerErrors !== TRUE) {
|
501 |
+
$fields = $customerForm->getAttributes();
|
502 |
+
foreach ($fields as $field) {
|
503 |
+
$requireds[$field->getAttributeCode()] = $field->getIsRequired();
|
504 |
+
}
|
505 |
+
//remove fields that we have data for
|
506 |
+
unset($requireds['firstname'], $requireds['lastname'], $requireds['email']);
|
507 |
+
$requireds = array_filter($requireds);
|
508 |
+
$html = '<div class="gigyaMoreInfo"><form action="' . Mage::getBaseUrl()
|
509 |
+
. 'gigyalogin/login" name="moreInfo" id="gigyaMoreInfoForm">';
|
510 |
+
foreach ($requireds as $key => $r) {
|
511 |
+
$requireds[$key] = $fields[$key]->getStoreLabel();
|
512 |
+
if (!$fields[$key]->getIsUserDefined()
|
513 |
+
&& is_object($this->getLayout()
|
514 |
+
->createBlock('customer/widget_' . $key))
|
515 |
+
) {
|
516 |
+
$html .= $this->getLayout()
|
517 |
+
->createBlock('customer/widget_' . $key)
|
518 |
+
->toHtml();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
}
|
520 |
+
else {
|
521 |
+
$html
|
522 |
+
.= '<div class="field">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
<label for="' . $key . '">' . $fields[$key]->getStoreLabel() . '</label>
|
524 |
<div class="input-box">
|
525 |
<input type="text" name="' . $key . '" id="' . $key . '" value="" class="input-text" />
|
526 |
</div>
|
527 |
</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
}
|
529 |
+
}
|
530 |
+
$html .= '<input class="button" id="gigyaMoreInfoSubmit" type="button" value="Send" onclick="gigyaFunctions.moreInfoSubmit()" "></form>';
|
531 |
+
$html .= '</div>';
|
532 |
+
|
533 |
+
$res = array(
|
534 |
+
'result' => 'moreInfo',
|
535 |
+
'fields' => $requireds,
|
536 |
+
'html' => $html,
|
537 |
+
);
|
538 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
539 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
540 |
+
|
541 |
+
return;
|
542 |
+
}
|
543 |
+
else {
|
544 |
+
$customerForm->compactData($customerData);
|
545 |
+
$customer->setPassword($this->getRequest()->getPost('password'));
|
546 |
+
$customer->setConfirmation($this->getRequest()
|
547 |
+
->getPost('confirmation'));
|
548 |
+
$customer->setPasswordConfirmation($this->getRequest()
|
549 |
+
->getPost('confirmation'));
|
550 |
+
$customerErrors = $customer->validate();
|
551 |
+
if (is_array($customerErrors)) {
|
552 |
+
$errors = array_merge($customerErrors, $errors);
|
553 |
+
}
|
554 |
}
|
555 |
|
556 |
+
$validationResult = count($errors) == 0;
|
557 |
+
|
558 |
+
if (TRUE === $validationResult) {
|
559 |
+
$params = $this->getRequest()->getParams();
|
560 |
+
Mage::dispatchEvent('gigya_pre_user_create', array(
|
561 |
+
'customer' => $customer,
|
562 |
+
'gigya_data' => $params['gigyaData']
|
563 |
+
));
|
564 |
+
$customer->save();
|
565 |
+
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($params['gigyaData']);
|
566 |
+
if ($updater->isMapped()) {
|
567 |
+
$updater->updateMagentoAccount($customer);
|
568 |
+
}
|
569 |
+
Mage::dispatchEvent('customer_register_success',
|
570 |
+
array('account_controller' => $this, 'customer' => $customer)
|
571 |
+
);
|
572 |
+
|
573 |
+
if ($customer->isConfirmationRequired()) {
|
574 |
+
$customer->sendNewAccountEmail(
|
575 |
+
'confirmation',
|
576 |
+
$session->getBeforeAuthUrl(),
|
577 |
+
Mage::app()->getStore()->getId()
|
578 |
+
);
|
579 |
+
$session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.',
|
580 |
+
Mage::helper('customer')
|
581 |
+
->getEmailConfirmationUrl($customer->getEmail())));
|
582 |
|
583 |
return;
|
584 |
+
}
|
585 |
+
else {
|
586 |
+
$session->setCustomerAsLoggedIn($customer);
|
587 |
+
$url = $this->_welcomeCustomer($customer);
|
588 |
+
//$url = Mage::getUrl('customer/account');
|
589 |
+
//$this->_redirectSuccess($url);
|
590 |
+
$res = array(
|
591 |
+
'result' => 'newUser',
|
592 |
+
'redirect' => $url
|
593 |
+
);
|
594 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
595 |
+
$this->getResponse()->setBody(Mage::helper('core')
|
596 |
+
->jsonEncode($res));
|
597 |
+
}
|
598 |
}
|
599 |
+
else {
|
600 |
+
Mage::log($errors . __FILE__ . ' ' . __LINE__);
|
601 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
602 |
+
$error = '';
|
603 |
+
if (is_array($errors)) {
|
604 |
+
foreach ($errors as $errorMessage) {
|
605 |
+
$session->addError($errorMessage);
|
606 |
+
$error .= $errorMessage . "\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
}
|
608 |
+
$res['result'] = 'error';
|
609 |
+
$res['message'] = $error;
|
610 |
+
}
|
611 |
+
else {
|
612 |
+
$res['result'] = 'error';
|
613 |
+
$res['message'] = $this->__('Invalid customer data');
|
614 |
+
}
|
615 |
}
|
616 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
617 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
618 |
+
} catch (Mage_Core_Exception $e) {
|
619 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
620 |
+
if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
|
621 |
+
$message = $this->__('There is already an account with this email address.');
|
622 |
+
}
|
623 |
+
else {
|
624 |
+
$message = $e->getMessage();
|
625 |
+
}
|
626 |
+
$res['result'] = 'error';
|
627 |
+
$res['message'] = $message;
|
628 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
629 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
630 |
+
} catch (Exception $e) {
|
631 |
+
$session->setCustomerFormData($this->getRequest()->getPost())
|
632 |
+
->addException($e, $this->__('Cannot save the customer.'));
|
633 |
+
$message = $this->__('Cannot save the customer.');
|
634 |
+
$res['result'] = 'error';
|
635 |
+
$res['message'] = $message;
|
636 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
637 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
638 |
+
}
|
639 |
}
|
640 |
|
641 |
+
Mage::log('error ' . __FILE__ . ' ' . __LINE__);
|
642 |
+
//$this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Login post action
|
647 |
+
*/
|
648 |
+
public function loginPostAction() {
|
649 |
+
if ($this->_getSession()->isLoggedIn()) {
|
650 |
+
$res['result'] = 'error';
|
651 |
+
$res['message'] = $this->__('User is logged in.');
|
652 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
653 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
654 |
+
|
655 |
+
return;
|
656 |
+
}
|
657 |
+
$session = $this->_getSession();
|
658 |
|
659 |
+
if ($this->getRequest()->isPost()) {
|
660 |
+
$login = Mage::helper('core')->jsonDecode($this->getRequest()
|
661 |
+
->getPost('login'));
|
662 |
+
if (!empty($login['username']) && !empty($login['password'])) {
|
663 |
+
$res = array();
|
664 |
+
try {
|
665 |
+
$session->login($login['username'], $login['password']);
|
666 |
+
if ($session->getCustomer()->getIsJustConfirmed()) {
|
667 |
+
$this->_welcomeCustomer($session->getCustomer(), TRUE);
|
668 |
+
}
|
669 |
+
$res['result'] = 'success';
|
670 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
671 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
672 |
+
} catch (Mage_Core_Exception $e) {
|
673 |
+
switch ($e->getCode()) {
|
674 |
+
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
|
675 |
+
$value = Mage::helper('customer')
|
676 |
+
->getEmailConfirmationUrl($login['username']);
|
677 |
+
$message = Mage::helper('customer')
|
678 |
+
->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.',
|
679 |
+
$value);
|
680 |
+
break;
|
681 |
+
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
|
682 |
+
$message = $e->getMessage();
|
683 |
+
break;
|
684 |
+
default:
|
685 |
+
$message = $e->getMessage();
|
686 |
+
}
|
687 |
+
$res['result'] = 'error';
|
688 |
+
$res['message'] = $message;
|
689 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
690 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
691 |
+
} catch (Exception $e) {
|
692 |
+
// Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
|
693 |
+
}
|
694 |
+
}
|
695 |
+
else {
|
696 |
+
$res['result'] = 'error';
|
697 |
+
$res['message'] = $this->__('Login and password are required.');
|
698 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
699 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
700 |
+
}
|
701 |
}
|
702 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
703 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
704 |
+
}
|
705 |
+
|
706 |
+
public function logoutAction() {
|
707 |
+
$cust = $this->_getSession()->logout()->setBeforeAuthUrl(NULL);
|
708 |
+
if ($cust->getId() === NULL) {
|
709 |
+
$res['result'] = 'success';
|
710 |
+
}
|
711 |
+
else {
|
712 |
+
$res['result'] = 'error';
|
713 |
+
}
|
714 |
+
|
715 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
716 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($res));
|
717 |
+
exit();
|
718 |
+
}
|
719 |
|
720 |
}
|
721 |
|
app/code/community/Gigya/Social/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Gigya_Social>
|
5 |
-
<version>3.2.
|
6 |
</Gigya_Social>
|
7 |
</modules>
|
8 |
<frontend>
|
@@ -42,6 +42,15 @@
|
|
42 |
</gigya_logout>
|
43 |
</observers>
|
44 |
</customer_logout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
<checkout_cart_product_add_after>
|
46 |
<observers>
|
47 |
<gigya_share_action>
|
@@ -74,7 +83,7 @@
|
|
74 |
</gigya_reviewRemainder>
|
75 |
</observers>
|
76 |
</checkout_onepage_controller_success_action>
|
77 |
-
<
|
78 |
<observers>
|
79 |
<gender_convert>
|
80 |
<type>singleton</type>
|
@@ -82,7 +91,7 @@
|
|
82 |
<method>convertGenderFromGigya</method>
|
83 |
</gender_convert>
|
84 |
</observers>
|
85 |
-
</
|
86 |
</events>
|
87 |
<routers>
|
88 |
<gigyalogin>
|
@@ -292,6 +301,7 @@
|
|
292 |
<RegisterScreen>gigya-register-screen</RegisterScreen>
|
293 |
<ProfileWebScreen>Default-ProfileUpdate</ProfileWebScreen>
|
294 |
<override_links>1</override_links>
|
|
|
295 |
</gigya_raas_conf>
|
296 |
</gigya_login>
|
297 |
<gigya_share>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Gigya_Social>
|
5 |
+
<version>3.2.1</version>
|
6 |
</Gigya_Social>
|
7 |
</modules>
|
8 |
<frontend>
|
42 |
</gigya_logout>
|
43 |
</observers>
|
44 |
</customer_logout>
|
45 |
+
<customer_session_init>
|
46 |
+
<observers>
|
47 |
+
<gigya_raas_relogin>
|
48 |
+
<type>singleton</type>
|
49 |
+
<class>Gigya_Social_Model_Customer_Observer</class>
|
50 |
+
<method>reLoginToGigya</method>
|
51 |
+
</gigya_raas_relogin>
|
52 |
+
</observers>
|
53 |
+
</customer_session_init>
|
54 |
<checkout_cart_product_add_after>
|
55 |
<observers>
|
56 |
<gigya_share_action>
|
83 |
</gigya_reviewRemainder>
|
84 |
</observers>
|
85 |
</checkout_onepage_controller_success_action>
|
86 |
+
<gigya_pre_field_mapping>
|
87 |
<observers>
|
88 |
<gender_convert>
|
89 |
<type>singleton</type>
|
91 |
<method>convertGenderFromGigya</method>
|
92 |
</gender_convert>
|
93 |
</observers>
|
94 |
+
</gigya_pre_field_mapping>
|
95 |
</events>
|
96 |
<routers>
|
97 |
<gigyalogin>
|
301 |
<RegisterScreen>gigya-register-screen</RegisterScreen>
|
302 |
<ProfileWebScreen>Default-ProfileUpdate</ProfileWebScreen>
|
303 |
<override_links>1</override_links>
|
304 |
+
<session_lead>gigya</session_lead>
|
305 |
</gigya_raas_conf>
|
306 |
</gigya_login>
|
307 |
<gigya_share>
|
app/code/community/Gigya/Social/etc/mappings.json
CHANGED
@@ -12,5 +12,11 @@
|
|
12 |
"gigyaName": "data.test",
|
13 |
"gigyaType": "string",
|
14 |
"direction": "g2cms"
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
]
|
12 |
"gigyaName": "data.test",
|
13 |
"gigyaType": "string",
|
14 |
"direction": "g2cms"
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"magentoName": "firstname",
|
18 |
+
"magentoType": "string",
|
19 |
+
"gigyaName": "profile.firstName",
|
20 |
+
"gigyaType": "string"
|
21 |
}
|
22 |
]
|
app/code/community/Gigya/Social/etc/system.xml
CHANGED
@@ -296,6 +296,15 @@
|
|
296 |
<show_in_website>1</show_in_website>
|
297 |
<show_in_store>1</show_in_store>
|
298 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
<title translate="label">
|
300 |
<lable>Registration-as-a-Service</lable>
|
301 |
<frontend_type>label</frontend_type>
|
296 |
<show_in_website>1</show_in_website>
|
297 |
<show_in_store>1</show_in_store>
|
298 |
<fields>
|
299 |
+
<session_lead translate="label">
|
300 |
+
<label>Session management</label>
|
301 |
+
<frontend_type>select</frontend_type>
|
302 |
+
<source_model>Gigya_Social_Model_Config_Source_Lead</source_model>
|
303 |
+
<sort_order>9</sort_order>
|
304 |
+
<show_in_default>1</show_in_default>
|
305 |
+
<show_in_website>1</show_in_website>
|
306 |
+
<show_in_store>1</show_in_store>
|
307 |
+
</session_lead>
|
308 |
<title translate="label">
|
309 |
<lable>Registration-as-a-Service</lable>
|
310 |
<frontend_type>label</frontend_type>
|
app/code/community/Gigya/Social/sdk/gigyaCMS.php
CHANGED
@@ -20,23 +20,17 @@ class GigyaCMS
|
|
20 |
/**
|
21 |
* Constructs a GigyaApi object.
|
22 |
*/
|
23 |
-
public function __construct(
|
24 |
-
$apiKey,
|
25 |
-
$secret,
|
26 |
-
$apiDomain,
|
27 |
-
$userSecret = null,
|
28 |
-
$userKey = null,
|
29 |
-
$useUserKey = true,
|
30 |
$debug = false
|
31 |
-
)
|
32 |
-
|
33 |
-
$this->api_key
|
34 |
-
$this->api_secret
|
35 |
-
$this->api_domain
|
36 |
-
$this->user_key
|
37 |
-
$this->user_secret
|
38 |
-
$this->useUserKey
|
39 |
-
$this->debug
|
40 |
|
41 |
}
|
42 |
|
@@ -60,14 +54,14 @@ class GigyaCMS
|
|
60 |
} else {
|
61 |
$request = new GSRequest($this->api_key, $this->api_secret, $method, null, true);
|
62 |
}
|
63 |
-
$user_info
|
64 |
-
$envParams
|
65 |
-
"cms_name"
|
66 |
"cms_version" => Mage::getVersion(),
|
67 |
"gigya_version" => Mage::helper('Gigya_Social')->getExtensionVersion()
|
68 |
);
|
69 |
$params['environment'] = json_encode($envParams);
|
70 |
-
if (
|
71 |
foreach ($params as $param => $val) {
|
72 |
$request->setParam($param, $val);
|
73 |
}
|
@@ -78,7 +72,7 @@ class GigyaCMS
|
|
78 |
// To be define on CMS code (or not).
|
79 |
|
80 |
// Set the request path.
|
81 |
-
$domain = !
|
82 |
$request->setAPIDomain($domain);
|
83 |
$request->setCAFile(__DIR__ . DIRECTORY_SEPARATOR . "cacert.pem");
|
84 |
|
@@ -90,8 +84,10 @@ class GigyaCMS
|
|
90 |
// Check for errors
|
91 |
$err_code = $response->getErrorCode();
|
92 |
if ($err_code != 0) {
|
93 |
-
Mage::log(
|
94 |
-
. $
|
|
|
|
|
95 |
if ($retrys < $trys) {
|
96 |
$this->call($method, $params, $trys++);
|
97 |
}
|
@@ -145,7 +141,7 @@ class GigyaCMS
|
|
145 |
{
|
146 |
static $user_info = null;
|
147 |
if ($user_info === null) {
|
148 |
-
if (
|
149 |
$params = array(
|
150 |
'uid' => $guid,
|
151 |
);
|
@@ -174,7 +170,7 @@ class GigyaCMS
|
|
174 |
*/
|
175 |
public function userLogout($guid)
|
176 |
{
|
177 |
-
if (
|
178 |
$params = array(
|
179 |
'uid' => $guid,
|
180 |
);
|
@@ -198,7 +194,7 @@ class GigyaCMS
|
|
198 |
*/
|
199 |
public function getFriends($guid, $params = array())
|
200 |
{
|
201 |
-
if (
|
202 |
$params += array(
|
203 |
'uid' => $guid,
|
204 |
);
|
@@ -278,12 +274,12 @@ class GigyaCMS
|
|
278 |
$params['siteUID'] = $uid;
|
279 |
|
280 |
// Set a new user flag if true.
|
281 |
-
if (
|
282 |
$params['newUser'] = true;
|
283 |
}
|
284 |
|
285 |
// Add user info.
|
286 |
-
if (
|
287 |
$params['userInfo'] = json_encode($user_info);
|
288 |
}
|
289 |
|
@@ -292,8 +288,10 @@ class GigyaCMS
|
|
292 |
|
293 |
//Set Gigya cookie.
|
294 |
try {
|
295 |
-
setcookie(
|
296 |
-
$response["
|
|
|
|
|
297 |
} catch (Exception $e) {
|
298 |
error_log(sprintf('error string gigya cookie'));
|
299 |
error_log(sprintf('error message : @error', array('@error' => $e->getMessage())));
|
@@ -313,7 +311,7 @@ class GigyaCMS
|
|
313 |
*/
|
314 |
public function notifyRegistration($guid, $uid)
|
315 |
{
|
316 |
-
if (
|
317 |
$params = array(
|
318 |
'uid' => $guid,
|
319 |
'siteUID' => $uid,
|
@@ -335,7 +333,7 @@ class GigyaCMS
|
|
335 |
*/
|
336 |
public function deleteUser($uid)
|
337 |
{
|
338 |
-
if (
|
339 |
$params = array(
|
340 |
'uid' => $uid,
|
341 |
);
|
@@ -394,8 +392,11 @@ class GigyaCMS
|
|
394 |
|
395 |
// Because we can only trust the UID parameter from the origin object,
|
396 |
// We'll ask Gigya's API for account-info straight from the server.
|
397 |
-
|
398 |
-
|
|
|
|
|
|
|
399 |
}
|
400 |
|
401 |
/**
|
@@ -565,7 +566,7 @@ class GigyaCMS
|
|
565 |
public static function advancedValuesParser($values)
|
566 |
{
|
567 |
|
568 |
-
if (
|
569 |
$lines = array();
|
570 |
$values = explode("\n", $values);
|
571 |
|
20 |
/**
|
21 |
* Constructs a GigyaApi object.
|
22 |
*/
|
23 |
+
public function __construct($apiKey, $secret, $apiDomain, $userSecret = null, $userKey = null, $useUserKey = true,
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
$debug = false
|
25 |
+
)
|
26 |
+
{
|
27 |
+
$this->api_key = $apiKey;
|
28 |
+
$this->api_secret = $secret;
|
29 |
+
$this->api_domain = $apiDomain;
|
30 |
+
$this->user_key = $userKey;
|
31 |
+
$this->user_secret = $userSecret;
|
32 |
+
$this->useUserKey = $useUserKey;
|
33 |
+
$this->debug = $debug;
|
34 |
|
35 |
}
|
36 |
|
54 |
} else {
|
55 |
$request = new GSRequest($this->api_key, $this->api_secret, $method, null, true);
|
56 |
}
|
57 |
+
$user_info = null;
|
58 |
+
$envParams = array(
|
59 |
+
"cms_name" => "magento",
|
60 |
"cms_version" => Mage::getVersion(),
|
61 |
"gigya_version" => Mage::helper('Gigya_Social')->getExtensionVersion()
|
62 |
);
|
63 |
$params['environment'] = json_encode($envParams);
|
64 |
+
if (!empty($params)) {
|
65 |
foreach ($params as $param => $val) {
|
66 |
$request->setParam($param, $val);
|
67 |
}
|
72 |
// To be define on CMS code (or not).
|
73 |
|
74 |
// Set the request path.
|
75 |
+
$domain = !empty($this->api_domain) ? $this->api_domain : 'us1.gigya.com';
|
76 |
$request->setAPIDomain($domain);
|
77 |
$request->setCAFile(__DIR__ . DIRECTORY_SEPARATOR . "cacert.pem");
|
78 |
|
84 |
// Check for errors
|
85 |
$err_code = $response->getErrorCode();
|
86 |
if ($err_code != 0) {
|
87 |
+
Mage::log(
|
88 |
+
"Error sending " . $method . " to Gigya. error code was " . $err_code . " error message was "
|
89 |
+
. $response->getErrorMessage() . " Gigya callId was " . $response->getString("callId"), Zend_Log::ERR
|
90 |
+
);
|
91 |
if ($retrys < $trys) {
|
92 |
$this->call($method, $params, $trys++);
|
93 |
}
|
141 |
{
|
142 |
static $user_info = null;
|
143 |
if ($user_info === null) {
|
144 |
+
if (!empty($guid)) {
|
145 |
$params = array(
|
146 |
'uid' => $guid,
|
147 |
);
|
170 |
*/
|
171 |
public function userLogout($guid)
|
172 |
{
|
173 |
+
if (!empty($guid)) {
|
174 |
$params = array(
|
175 |
'uid' => $guid,
|
176 |
);
|
194 |
*/
|
195 |
public function getFriends($guid, $params = array())
|
196 |
{
|
197 |
+
if (!empty($guid)) {
|
198 |
$params += array(
|
199 |
'uid' => $guid,
|
200 |
);
|
274 |
$params['siteUID'] = $uid;
|
275 |
|
276 |
// Set a new user flag if true.
|
277 |
+
if (!empty($is_new_user)) {
|
278 |
$params['newUser'] = true;
|
279 |
}
|
280 |
|
281 |
// Add user info.
|
282 |
+
if (!empty($user_info)) {
|
283 |
$params['userInfo'] = json_encode($user_info);
|
284 |
}
|
285 |
|
288 |
|
289 |
//Set Gigya cookie.
|
290 |
try {
|
291 |
+
setcookie(
|
292 |
+
$response["cookieName"], $response["cookieValue"], 0, $response["cookiePath"],
|
293 |
+
$response["cookieDomain"]
|
294 |
+
);
|
295 |
} catch (Exception $e) {
|
296 |
error_log(sprintf('error string gigya cookie'));
|
297 |
error_log(sprintf('error message : @error', array('@error' => $e->getMessage())));
|
311 |
*/
|
312 |
public function notifyRegistration($guid, $uid)
|
313 |
{
|
314 |
+
if (!empty($guid) && !empty($uid)) {
|
315 |
$params = array(
|
316 |
'uid' => $guid,
|
317 |
'siteUID' => $uid,
|
333 |
*/
|
334 |
public function deleteUser($uid)
|
335 |
{
|
336 |
+
if (!empty($uid)) {
|
337 |
$params = array(
|
338 |
'uid' => $uid,
|
339 |
);
|
392 |
|
393 |
// Because we can only trust the UID parameter from the origin object,
|
394 |
// We'll ask Gigya's API for account-info straight from the server.
|
395 |
+
$gigyaAccount = $this->call('accounts.getAccountInfo', $req_params, 1);
|
396 |
+
$accountObject = (object) $gigyaAccount;
|
397 |
+
Mage::dispatchEvent("gigya_post_account_fetch", array("gigyaAccount" => $accountObject));
|
398 |
+
$gigyaAccount = (array) $accountObject;
|
399 |
+
return $gigyaAccount;
|
400 |
}
|
401 |
|
402 |
/**
|
566 |
public static function advancedValuesParser($values)
|
567 |
{
|
568 |
|
569 |
+
if (!empty($values)) {
|
570 |
$lines = array();
|
571 |
$values = explode("\n", $values);
|
572 |
|
app/code/community/Gigya/Social/tests/TestGigyaCms.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PhpStorm.
|
5 |
-
* User: Yaniv Aran-Shamir
|
6 |
-
* Date: 6/6/16
|
7 |
-
* Time: 9:04 AM
|
8 |
-
*/
|
9 |
-
include_once "../sdk/gigyaCMS.php";
|
10 |
-
class TestGigyaCms extends PHPUnit_Framework_TestCase
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @var PHPUnit_Framework_MockObject_MockObject
|
15 |
-
*/
|
16 |
-
private $gigyaCms;
|
17 |
-
|
18 |
-
public function testIsRaasFalse()
|
19 |
-
{
|
20 |
-
$this->gigyaCms->expects($this->once())->method('call')->with($this->equalTo("accounts.getSchema"), $this->equalTo(array()))->willReturn(403036);
|
21 |
-
$this->assertFalse($this->gigyaCms->isRaaS());
|
22 |
-
|
23 |
-
}
|
24 |
-
public function testIsRaasTrue()
|
25 |
-
{
|
26 |
-
$this->gigyaCms->expects($this->once())->method('call')->with($this->equalTo("accounts.getSchema"), $this->equalTo(array()))->willReturn(array());
|
27 |
-
$this->assertTrue($this->gigyaCms->isRaaS());
|
28 |
-
|
29 |
-
}
|
30 |
-
|
31 |
-
public function testExchangeUidSigRaas()
|
32 |
-
{
|
33 |
-
$uid = "123456";
|
34 |
-
$timestamp = time();
|
35 |
-
$sig = sha1($timestamp . $uid);
|
36 |
-
$this->gigyaCms->expects($this->once())->method('call')->with($this->equalTo("accounts.exchangeUIDSignature"), $this->equalTo(array(
|
37 |
-
"UID" => $uid,
|
38 |
-
"signatureTimestamp" => $timestamp,
|
39 |
-
"UIDSignature" => $sig
|
40 |
-
)));
|
41 |
-
$this->gigyaCms->exchangeUidSignature($uid, $sig, $timestamp, "raas");
|
42 |
-
}
|
43 |
-
|
44 |
-
public function testtestExchangeUidSigSocial()
|
45 |
-
{
|
46 |
-
$uid = "123456";
|
47 |
-
$timestamp = time();
|
48 |
-
$sig = sha1($timestamp . $uid);
|
49 |
-
$this->gigyaCms->expects($this->once())->method('call')->with($this->equalTo("socialize.exchangeUIDSignature"), $this->equalTo(array(
|
50 |
-
"UID" => $uid,
|
51 |
-
"signatureTimestamp" => $timestamp,
|
52 |
-
"UIDSignature" => $sig
|
53 |
-
)));
|
54 |
-
$this->gigyaCms->exchangeUidSignature($uid, $sig, $timestamp, "socialize");
|
55 |
-
}
|
56 |
-
|
57 |
-
protected function setUp()
|
58 |
-
{
|
59 |
-
$this->gigyaCms = $this->getMockBuilder("GigyaCMS")
|
60 |
-
->setMethods(["call"])
|
61 |
-
->getMock();
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/adminTests/GigyaUpdaterTest.php
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PhpStorm.
|
5 |
-
* User: Yaniv Aran-Shamir
|
6 |
-
* Date: 6/7/16
|
7 |
-
* Time: 1:14 PM
|
8 |
-
*/
|
9 |
-
class GigyaUpdaterTest extends PHPUnit_Framework_TestCase
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @var Mage_Customer_Model_Customer
|
14 |
-
*/
|
15 |
-
private $magentoAccount;
|
16 |
-
|
17 |
-
/* public function testGigyaAccountUpdate()
|
18 |
-
{
|
19 |
-
$expectedArray = array(
|
20 |
-
"data" => array("test" => "test string"),
|
21 |
-
"profile" => array("gender" => "f")
|
22 |
-
);
|
23 |
-
$this->magentoAccount->setData("gender", 2);
|
24 |
-
$this->magentoAccount->setData("test1", "test string");
|
25 |
-
$gigyaUpdater = $this->getMockBuilder(Gigya_Social_Helper_FieldMapping_GigyaUpdater::class)
|
26 |
-
->setMethods(["callSetAccountInfo"])
|
27 |
-
->setConstructorArgs([$this->magentoAccount->getData(), $this->magentoAccount->getData("gigya_uid")])
|
28 |
-
->getMock();
|
29 |
-
|
30 |
-
$gigyaUpdater->setPath(__DIR__ . DS . ".." . DS . "resources" . DS . "mappings.json");
|
31 |
-
$gigyaUpdater->expects($this->once())->method("callSetAccountInfo");
|
32 |
-
$gigyaUpdater->updateGigya();
|
33 |
-
$garray = $gigyaUpdater->getGigyaArray();
|
34 |
-
$this->assertEquals($expectedArray, $garray);
|
35 |
-
}*/
|
36 |
-
|
37 |
-
public function testDeepValue()
|
38 |
-
{
|
39 |
-
$expectedArray = array(
|
40 |
-
"data" => array("deep" => array("deep" => array("deep" => array("very" => array("very" => array("deep" => array("value" => "test string"))))))),
|
41 |
-
);
|
42 |
-
$this->magentoAccount->setData("deep", "test string");
|
43 |
-
$gigyaUpdater = $this->getMockBuilder(Gigya_Social_Helper_FieldMapping_GigyaUpdater::class)
|
44 |
-
->setMethods(["callSetAccountInfo"])
|
45 |
-
->setConstructorArgs([$this->magentoAccount->getData(), $this->magentoAccount->getData("gigya_uid")])
|
46 |
-
->getMock();
|
47 |
-
|
48 |
-
$gigyaUpdater->setPath(__DIR__ . DS . ".." . DS . "resources" . DS . "mappings_deep.json");
|
49 |
-
$gigyaUpdater->expects($this->once())->method("callSetAccountInfo");
|
50 |
-
$gigyaUpdater->updateGigya();
|
51 |
-
$garray = $gigyaUpdater->getGigyaArray();
|
52 |
-
$this->assertEquals($expectedArray, $garray);
|
53 |
-
}
|
54 |
-
|
55 |
-
public function testCasting()
|
56 |
-
{
|
57 |
-
$string = "1";
|
58 |
-
$int = 1;
|
59 |
-
$long = 10000000000;
|
60 |
-
$bool = true;
|
61 |
-
|
62 |
-
$expectedArray = array(
|
63 |
-
"data" => array("string" => $string, "int" => $int, "long" => $long, "bool" => $bool )
|
64 |
-
);
|
65 |
-
$this->magentoAccount->setData("test_string", $int);
|
66 |
-
$this->magentoAccount->setData("test_int", $string);
|
67 |
-
$this->magentoAccount->setData("test_long", "10000000000");
|
68 |
-
$this->magentoAccount->setData("test_bool", "TRUE");
|
69 |
-
$gigyaUpdater = $this->getMockBuilder(Gigya_Social_Helper_FieldMapping_GigyaUpdater::class)
|
70 |
-
->setMethods(["callSetAccountInfo"])
|
71 |
-
->setConstructorArgs([$this->magentoAccount->getData(), $this->magentoAccount->getData("gigya_uid")])
|
72 |
-
->getMock();
|
73 |
-
|
74 |
-
$gigyaUpdater->setPath(__DIR__ . DS . ".." . DS . "resources" . DS . "mappings_casting_to_gigya.json");
|
75 |
-
$gigyaUpdater->expects($this->once())->method("callSetAccountInfo");
|
76 |
-
$gigyaUpdater->updateGigya();
|
77 |
-
$garray = $gigyaUpdater->getGigyaArray();
|
78 |
-
$this->assertEquals($expectedArray, $garray);
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
protected function setUp()
|
85 |
-
{
|
86 |
-
$this->magentoAccount = new Mage_Customer_Model_Customer();
|
87 |
-
$this->magentoAccount->setData("gigya_uid", "test_gigya_uid");
|
88 |
-
}
|
89 |
-
|
90 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/adminTests/TestApiKeyValidation.php
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PhpStorm.
|
5 |
-
* User: Yaniv Aran-Shamir
|
6 |
-
* Date: 6/2/16
|
7 |
-
* Time: 8:01 PM
|
8 |
-
*/
|
9 |
-
class TestApiKeyValidation extends PHPUnit_Framework_TestCase
|
10 |
-
{
|
11 |
-
const DATA = '{"field":"apikey","groups":{"gigya_global_conf":{"fields":{"enable":{"value":"1"},"apikey":{"value":"3_b2DQkw3a_SBnu0FD6d5b9v3cawzMjH1"},"encryptKeys":{"value":"1"},"useUserKey":{"value":"1"},"secretkey":{"value":""},"userKey":{"value":"AKL1jqD6uYz7"},"userSecret":{"value":"******"},"providers":{"value":"*"},"dataCenter":{"value":"us1.gigya.com"},"laguages":{"value":"auto"},"fallback_lang":{"value":"en"},"loginBehavior":{"value":"loginExistingUser"},"login_retries":{"value":"2"},"google_sa":{"value":"0"},"counters":{"value":"0"},"debug_log":{"value":"0"},"advancedConfig":{"value":""}}}},"group_id":"gigya_global_conf","store_code":"","website_code":"","scope":"default","scope_id":0,"field_config":{"@attributes":{"translate":"label"},"label":"Gigya API key","frontend_type":"text","backend_model":"Gigya_Social_Model_Config_Backend_ApiKey","comment":"Specify the Gigya API key for this domain","sort_order":"9","show_in_default":"1","show_in_website":"1","show_in_store":"1"},"fieldset_data":{"enable":"1","apikey":"3_b2DQkw3a_SBnu0FD6d5b9v3cawzMjH1fhNpw6vctcukk6ZBuxPxj5W3nlFdBOdIN","encryptKeys":"1","useUserKey":"1","secretkey":"","userKey":"AKL1jqD6uYz7","userSecret":"******","providers":"*","dataCenter":"us1.gigya.com","laguages":"auto","fallback_lang":"en","loginBehavior":"loginExistingUser","login_retries":"2","google_sa":"0","counters":"0","debug_log":"0","advancedConfig":""},"path":"gigya_global\/gigya_global_conf\/apikey","value":"3_b2DQkw3a_SBnu0FD6d5b9v3cawzMjH1fhNpw6vctcukk6ZBuxPxj5W3nlFdBOdIN","config_id":"1523"}';
|
12 |
-
private $data;
|
13 |
-
|
14 |
-
public function testMissingUserKey()
|
15 |
-
{
|
16 |
-
$this->setExpectedException(Mage_Core_Exception::class, "Gigya user key is required.");
|
17 |
-
$newData = $this->data;
|
18 |
-
$newData['fieldset_data']['userKey'] = "";
|
19 |
-
$mock = $this->buildMock($newData);
|
20 |
-
$beforeSave = new ReflectionMethod("Gigya_Social_Model_Config_Backend_ApiKey", "_beforeSave");
|
21 |
-
$beforeSave->setAccessible(true);
|
22 |
-
$beforeSave->invoke($mock);
|
23 |
-
}
|
24 |
-
|
25 |
-
public function testMissingApiKey()
|
26 |
-
{
|
27 |
-
$this->setExpectedException(Mage_Core_Exception::class, "Gigya apiKey is required");
|
28 |
-
$newData = $this->data;
|
29 |
-
$newData['value'] = "";
|
30 |
-
$newData['fieldset_data']['apikey'] = "";
|
31 |
-
$newData['fieldset_data']['userSecret'] = "secret";
|
32 |
-
$mock = $this->buildMock($newData);
|
33 |
-
$beforeSave = new ReflectionMethod("Gigya_Social_Model_Config_Backend_ApiKey", "_beforeSave");
|
34 |
-
$beforeSave->setAccessible(true);
|
35 |
-
$beforeSave->invoke($mock);
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* This method is called before a test is executed.
|
40 |
-
*
|
41 |
-
*/
|
42 |
-
protected function setUp()
|
43 |
-
{
|
44 |
-
/* $req = new Mage_Core_Controller_Request_Http();
|
45 |
-
$res = new Mage_Core_Controller_Response_Http();
|
46 |
-
$controller = new Mage_Adminhtml_System_ConfigController($req, $res);*/
|
47 |
-
$this->data = json_decode(self::DATA, true);
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
protected function buildMock($dataArray)
|
55 |
-
{
|
56 |
-
$apiKeyValidator = $this->getMockBuilder("Gigya_Social_Model_Config_Backend_ApiKey")
|
57 |
-
->setMethods(array("getData", "getValue"))->getMock();
|
58 |
-
$apiKeyValidator->method("getData")
|
59 |
-
->willReturn($dataArray);
|
60 |
-
$apiKeyValidator->method("getValue")
|
61 |
-
->willReturn($dataArray['value']);
|
62 |
-
$apiKeyValidator->setData($dataArray);
|
63 |
-
return $apiKeyValidator;
|
64 |
-
}
|
65 |
-
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/adminTests/TestDefaultValues.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PhpStorm.
|
5 |
-
* User: Yaniv Aran-Shamir
|
6 |
-
* Date: 6/1/16
|
7 |
-
* Time: 5:24 PM
|
8 |
-
*/
|
9 |
-
class TestDefaultValues extends PHPUnit_Framework_TestCase
|
10 |
-
{
|
11 |
-
|
12 |
-
|
13 |
-
public function testDefaultValue()
|
14 |
-
{
|
15 |
-
echo "Testing default configuration values" . PHP_EOL;
|
16 |
-
echo "Checking enabled by default" . PHP_EOL;
|
17 |
-
$this->assertEquals(1, reset(Mage::getConfig()->getNode("default/gigya_global/gigya_global_conf/enable")));
|
18 |
-
echo "checking default data center" . PHP_EOL;
|
19 |
-
$this->assertEquals("us1.gigya.com", reset(Mage::getConfig()->getNode("default/gigya_global/gigya_global_conf/dataCenter")));
|
20 |
-
}
|
21 |
-
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/bootstrap.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PhpStorm.
|
5 |
-
* User: Yaniv Aran-Shamir
|
6 |
-
* Date: 6/1/16
|
7 |
-
* Time: 5:27 PM
|
8 |
-
*/
|
9 |
-
class bootstrap
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* bootstrap constructor.
|
14 |
-
*/
|
15 |
-
public function __construct()
|
16 |
-
{
|
17 |
-
echo "Loading Magento\n";
|
18 |
-
require_once( MAGENTO_ROOT . '/app/Mage.php' );
|
19 |
-
Mage::app();
|
20 |
-
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
// Autoload:
|
25 |
-
new Bootstrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/frontendTests/Gigya_Social_AccountControllerTest.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PhpStorm.
|
5 |
-
* User: Yaniv Aran-Shamir
|
6 |
-
* Date: 6/6/16
|
7 |
-
* Time: 1:22 PM
|
8 |
-
*/
|
9 |
-
class Gigya_Social_AccountControllerTest extends PHPUnit_Framework_TestCase
|
10 |
-
{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
public function testAccountUpdate()
|
15 |
-
{
|
16 |
-
|
17 |
-
}
|
18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/frontendTests/MagentoUpdaterTest.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PhpStorm.
|
5 |
-
* User: Yaniv Aran-Shamir
|
6 |
-
* Date: 6/6/16
|
7 |
-
* Time: 1:51 PM
|
8 |
-
*/
|
9 |
-
class MagentoUpdaterTest extends PHPUnit_Framework_TestCase
|
10 |
-
{
|
11 |
-
|
12 |
-
private $gigyaAccount;
|
13 |
-
/**
|
14 |
-
* @var Mage_Customer_Model_Customer
|
15 |
-
*/
|
16 |
-
private $magentoAccount;
|
17 |
-
|
18 |
-
public function testUpdateAccount()
|
19 |
-
{
|
20 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaAccount);
|
21 |
-
$updater->setPath(__DIR__ . DS . ".." . DS . "resources" . DS . "mappings.json");
|
22 |
-
$updater->updateMagentoAccount($this->magentoAccount);
|
23 |
-
$this->assertEquals(1, $this->magentoAccount->getData("gender"));
|
24 |
-
$this->assertEquals("test string", $this->magentoAccount->getData("test1"));
|
25 |
-
}
|
26 |
-
|
27 |
-
public function testVeryDeepValue()
|
28 |
-
{
|
29 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaAccount);
|
30 |
-
$updater->setPath(__DIR__ . DS . ".." . DS . "resources" . DS . "mappings_deep.json");
|
31 |
-
$updater->updateMagentoAccount($this->magentoAccount);
|
32 |
-
$this->assertEquals("very very deep", $this->magentoAccount->getData("deep"));
|
33 |
-
}
|
34 |
-
|
35 |
-
public function testArrayValue()
|
36 |
-
{
|
37 |
-
$json = '{"emails": ["pj00002he@btinternet.com"],"unverifiedEmails": []}';
|
38 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaAccount);
|
39 |
-
$updater->setPath(__DIR__ . DS . ".." . DS . "resources" . DS . "mappings_array.json");
|
40 |
-
$updater->updateMagentoAccount($this->magentoAccount);
|
41 |
-
$this->assertJsonStringEqualsJsonString($json, $this->magentoAccount->getData("array_test"));
|
42 |
-
}
|
43 |
-
|
44 |
-
public function testValueCasting()
|
45 |
-
{
|
46 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaAccount);
|
47 |
-
$updater->setPath(__DIR__ . DS . ".." . DS . "resources" . DS . "mappings_casting.json");
|
48 |
-
$updater->updateMagentoAccount($this->magentoAccount);
|
49 |
-
$this->assertTrue(is_numeric($this->magentoAccount->getData("test_int")), "Testing integer casting");
|
50 |
-
$this->assertTrue(is_string($this->magentoAccount->getData("test_string")), "Testing string casting");
|
51 |
-
$this->assertNotFalse(strtotime($this->magentoAccount->getData("test_datetime_epoch")), "Testing datetime epoch casting");
|
52 |
-
$this->assertNotFalse(strtotime($this->magentoAccount->getData("test_datetime_string")), "Testing datetime string casting");
|
53 |
-
$this->assertTrue(is_float($this->magentoAccount->getData("test_float")), "Testing float casting");
|
54 |
-
}
|
55 |
-
|
56 |
-
public function testIsMapped()
|
57 |
-
{
|
58 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaAccount);
|
59 |
-
$this->assertTrue($updater->isMapped(), "Testing mapped is set to true");
|
60 |
-
Mage::getConfig()->setNode("global/gigya/mapping_file", "");
|
61 |
-
$updater = new Gigya_Social_Helper_FieldMapping_MagentoUpdater($this->gigyaAccount);
|
62 |
-
$this->assertFalse($updater->isMapped(), "Testing mapped is false");
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Sets up the fixture, for example, open a network connection.
|
67 |
-
* This method is called before a test is executed.
|
68 |
-
*
|
69 |
-
*/
|
70 |
-
protected function setUp()
|
71 |
-
{
|
72 |
-
$json = file_get_contents(__DIR__ . DS . ".." . DS . "resources" . DS . "account.json");
|
73 |
-
$this->gigyaAccount = json_decode($json, true);
|
74 |
-
$this->magentoAccount = $this->getMockBuilder(Mage_Customer_Model_Customer::class)
|
75 |
-
->setMethods(["save"])->getMock();
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/phpunit.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
3 |
-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
4 |
-
bootstrap="bootstrap.php"
|
5 |
-
colors="true"
|
6 |
-
verbose="true">
|
7 |
-
<php>
|
8 |
-
<const name="MAGENTO_ROOT" value="../../../../../../"/>
|
9 |
-
</php>
|
10 |
-
<testsuites>
|
11 |
-
<testsuite name="Admin Tests">
|
12 |
-
<directory>./adminTests</directory>
|
13 |
-
</testsuite>
|
14 |
-
</testsuites>
|
15 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/resources/account.json
DELETED
@@ -1,93 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"UID": "9b792cd0d4df4c9d938402ea793f33e6",
|
3 |
-
"isRegistered": true,
|
4 |
-
"isActive": true,
|
5 |
-
"isLockedOut": false,
|
6 |
-
"isVerified": true,
|
7 |
-
"iRank": 0,
|
8 |
-
"loginIDs": {
|
9 |
-
"emails": [
|
10 |
-
"pj00002he@btinternet.com"
|
11 |
-
],
|
12 |
-
"unverifiedEmails": []
|
13 |
-
},
|
14 |
-
"emails": {
|
15 |
-
"verified": [
|
16 |
-
"pj00002he@btinternet.com"
|
17 |
-
],
|
18 |
-
"unverified": []
|
19 |
-
},
|
20 |
-
"socialProviders": "site",
|
21 |
-
"profile": {
|
22 |
-
"work": {
|
23 |
-
"company": "ibm"
|
24 |
-
},
|
25 |
-
"firstName": "Test",
|
26 |
-
"lastName": "Testme",
|
27 |
-
"birthYear": 1981,
|
28 |
-
"birthMonth": 10,
|
29 |
-
"birthDay": 17,
|
30 |
-
"city": "NYC",
|
31 |
-
"zip": "12356",
|
32 |
-
"gender": "m",
|
33 |
-
"age": 33,
|
34 |
-
"email": "pj00002he@btinternet.com"
|
35 |
-
},
|
36 |
-
"identities": [
|
37 |
-
{
|
38 |
-
"provider": "site",
|
39 |
-
"providerUID": "9b792cd0d4df4c9d938402ea793f33e6",
|
40 |
-
"isLoginIdentity": false,
|
41 |
-
"firstName": "Test",
|
42 |
-
"lastName": "Testme",
|
43 |
-
"gender": "m",
|
44 |
-
"age": "33",
|
45 |
-
"birthDay": "17",
|
46 |
-
"birthMonth": "10",
|
47 |
-
"birthYear": "1981",
|
48 |
-
"email": "pj00002he@btinternet.com",
|
49 |
-
"city": "NYC",
|
50 |
-
"zip": "12356",
|
51 |
-
"allowsLogin": false,
|
52 |
-
"isExpiredSession": false,
|
53 |
-
"work": {
|
54 |
-
"company": "ibm"
|
55 |
-
},
|
56 |
-
"lastUpdated": "2015-01-21T01:43:48.106Z",
|
57 |
-
"lastUpdatedTimestamp": 1421804628106,
|
58 |
-
"oldestDataUpdated": "2014-10-21T13:47:17.251Z",
|
59 |
-
"oldestDataUpdatedTimestamp": 1413899237251
|
60 |
-
}
|
61 |
-
],
|
62 |
-
"data": {
|
63 |
-
"TSN": {
|
64 |
-
"myTsnEmailEnabled": "true"
|
65 |
-
},
|
66 |
-
"test": "test string",
|
67 |
-
"staging": "true",
|
68 |
-
"subscribe": "true",
|
69 |
-
"float": "12.4",
|
70 |
-
"deep": {"deep": {"deep": {"very": {"very":{"deep":{"value": "very very deep"}}}}}}
|
71 |
-
},
|
72 |
-
"password": {},
|
73 |
-
"created": "2014-03-25T18:08:52.829Z",
|
74 |
-
"createdTimestamp": 1395770932829,
|
75 |
-
"lastUpdated": "2015-01-21T01:43:48.106Z",
|
76 |
-
"lastUpdatedTimestamp": 1421804628106,
|
77 |
-
"oldestDataUpdated": "2014-10-21T13:47:17.251Z",
|
78 |
-
"oldestDataUpdatedTimestamp": 1413899237251,
|
79 |
-
"registered": "2014-09-07T13:46:13.2041889Z",
|
80 |
-
"registeredTimestamp": 1410097573204,
|
81 |
-
"verified": "2014-12-03T15:03:23.636Z",
|
82 |
-
"verifiedTimestamp": 1417619003636,
|
83 |
-
"regSource": "",
|
84 |
-
"lastLoginLocation": {
|
85 |
-
"city": "Moorestown",
|
86 |
-
"state": "NJ",
|
87 |
-
"country": "US",
|
88 |
-
"coordinates": {
|
89 |
-
"lat": 39.97569274902344,
|
90 |
-
"lon": -74.94390106201172
|
91 |
-
}
|
92 |
-
}
|
93 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/resources/mappings.json
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
[
|
2 |
-
{
|
3 |
-
"magentoName": "gender",
|
4 |
-
"magentoType": "int",
|
5 |
-
"gigyaName": "profile.gender",
|
6 |
-
"gigyaType": "string",
|
7 |
-
"transFunc": "genderConvert",
|
8 |
-
"direction": "both"
|
9 |
-
},
|
10 |
-
{
|
11 |
-
"magentoName": "test1",
|
12 |
-
"magentoType": "string",
|
13 |
-
"gigyaName": "data.test",
|
14 |
-
"gigyaType": "string"
|
15 |
-
}
|
16 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/resources/mappings_array.json
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
[
|
2 |
-
{
|
3 |
-
"magentoName": "array_test",
|
4 |
-
"magentoType": "string",
|
5 |
-
"gigyaName": "loginIDs",
|
6 |
-
"gigyaType": "string"
|
7 |
-
}
|
8 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/resources/mappings_casting.json
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
[
|
2 |
-
{
|
3 |
-
"magentoName": "test_int",
|
4 |
-
"magentoType": "int",
|
5 |
-
"gigyaName": "profile.zip",
|
6 |
-
"gigyaType": "string"
|
7 |
-
},
|
8 |
-
{
|
9 |
-
"magentoName": "test_string",
|
10 |
-
"magentoType": "text",
|
11 |
-
"gigyaName": "profile.age",
|
12 |
-
"gigyaType": "int"
|
13 |
-
},
|
14 |
-
{
|
15 |
-
"magentoName": "test_datetime_epoch",
|
16 |
-
"magentoType": "datetime",
|
17 |
-
"gigyaName": "createdTimestamp",
|
18 |
-
"gigyaType": "long"
|
19 |
-
},
|
20 |
-
{
|
21 |
-
"magentoName": "test_datetime_string",
|
22 |
-
"magentoType": "datetime",
|
23 |
-
"gigyaName": "created",
|
24 |
-
"gigyaType": "string"
|
25 |
-
},
|
26 |
-
{
|
27 |
-
"magentoName": "test_float",
|
28 |
-
"magentoType": "decimal",
|
29 |
-
"gigyaName": "data.float",
|
30 |
-
"gigyaType": "string"
|
31 |
-
}
|
32 |
-
|
33 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/resources/mappings_casting_to_gigya.json
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
[
|
2 |
-
{
|
3 |
-
"magentoName": "test_string",
|
4 |
-
"magentoType": "int",
|
5 |
-
"gigyaName": "data.string",
|
6 |
-
"gigyaType": "string"
|
7 |
-
},
|
8 |
-
{
|
9 |
-
"magentoName": "test_int",
|
10 |
-
"magentoType": "text",
|
11 |
-
"gigyaName": "data.int",
|
12 |
-
"gigyaType": "int"
|
13 |
-
},
|
14 |
-
{
|
15 |
-
"magentoName": "test_long",
|
16 |
-
"magentoType": "string",
|
17 |
-
"gigyaName": "data.long",
|
18 |
-
"gigyaType": "long"
|
19 |
-
},
|
20 |
-
{
|
21 |
-
"magentoName": "test_bool",
|
22 |
-
"magentoType": "string",
|
23 |
-
"gigyaName": "data.bool",
|
24 |
-
"gigyaType": "bool"
|
25 |
-
}
|
26 |
-
|
27 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Gigya/Social/tests/resources/mappings_deep.json
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
[
|
2 |
-
{
|
3 |
-
"magentoName": "deep",
|
4 |
-
"magentoType": "string",
|
5 |
-
"gigyaName": "data.deep.deep.deep.very.very.deep.value",
|
6 |
-
"gigyaType": "string"
|
7 |
-
}
|
8 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/gigya/raas/onepage/screenset.phtml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: Yaniv Aran-Shamir
|
5 |
+
* Date: 7/24/16
|
6 |
+
* Time: 2:06 PM
|
7 |
+
*/
|
8 |
+
?>
|
9 |
+
<div class="col2-set">
|
10 |
+
<?php echo $this->getChildHtml('login_before') ?>
|
11 |
+
<div class="col-1">
|
12 |
+
<?php echo $this->getChildHtml('checkout.onepage.login.extra') ?>
|
13 |
+
<?php if ($this->getEmbed()) : ?>
|
14 |
+
<script type="text/javascript">//<![CDATA[
|
15 |
+
var gigyaScreenSets = gigyaMageSettings.RaaS.screenSets || [];
|
16 |
+
gigyaScreenSets.push(<?php echo $this->getParams(); ?>);
|
17 |
+
//]]>
|
18 |
+
</script>
|
19 |
+
<?php else : ?>
|
20 |
+
<script type="text/javascript">//<![CDATA[
|
21 |
+
function showScreens() {
|
22 |
+
gigya.accounts.showScreenSet(<?php echo $this->getParams(); ?>);
|
23 |
+
}
|
24 |
+
//]]>
|
25 |
+
</script>
|
26 |
+
<?php endif; ?>
|
27 |
+
<?php echo $this->getHtml() ?>
|
28 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
29 |
+
</div>
|
30 |
+
</div>
|
app/design/frontend/base/default/template/gigya/raas/screenset.phtml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: Yaniv Aran-Shamir
|
5 |
+
* Date: 7/24/16
|
6 |
+
* Time: 2:06 PM
|
7 |
+
*/
|
8 |
+
?>
|
9 |
+
<?php if ($this->getEmbed()) : ?>
|
10 |
+
<script type="text/javascript">//<![CDATA[
|
11 |
+
var gigyaScreenSets = gigyaMageSettings.RaaS.screenSets || [];
|
12 |
+
gigyaScreenSets.push(<?php echo $this->getParams(); ?>);
|
13 |
+
//]]>
|
14 |
+
</script>
|
15 |
+
<?php else : ?>
|
16 |
+
<script type="text/javascript" >//<![CDATA[
|
17 |
+
function showScreens()
|
18 |
+
{
|
19 |
+
gigya.accounts.showScreenSet(<?php echo $this->getParams(); ?>);
|
20 |
+
}
|
21 |
+
//]]>
|
22 |
+
</script>
|
23 |
+
<?php endif; ?>
|
24 |
+
<?php echo $this->getHtml() ?>
|
js/gigya/gigyaMagento.js
CHANGED
@@ -101,7 +101,7 @@ gigyaFunctions.RaaS.profileEdit = function (data) {
|
|
101 |
|
102 |
gigyaFunctions.RaaS.loginScreens = function (event) {
|
103 |
var params = gigyaMageSettings.RaaS,
|
104 |
-
|
105 |
if (typeof params.mobileScreenSet != 'undefined') {
|
106 |
jsonParams.mobileScreenSet = params.MobileScreen;
|
107 |
}
|
@@ -122,8 +122,8 @@ gigyaFunctions.RaaS.registerScreens = function (event) {
|
|
122 |
if (typeof params.mobileScreenSet != 'undefined') {
|
123 |
jsonParams.mobileScreenSet = params.MobileScreen;
|
124 |
}
|
125 |
-
if ((!params.override_links) && (params.raas_register_div_id.length
|
126 |
-
jsonParams.containerID = params.
|
127 |
gigya.accounts.showScreenSet(jsonParams);
|
128 |
} else {
|
129 |
if (event) {
|
@@ -190,18 +190,32 @@ gigyaFunctions.RaaS.init = function (params) {
|
|
190 |
gigyaFunctions.RaaS.profileScreens();
|
191 |
}
|
192 |
gigyaFunctions.RaaS.accountEmbed();
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
};
|
194 |
|
195 |
gigyaFunctions.RaaS.syncSession = function () {
|
196 |
gigya.accounts.getAccountInfo({
|
197 |
"callback": function (response) {
|
198 |
gigyaFunctions.RaaS.loggedIn = response.errorCode === 0;
|
199 |
-
if (gigyaMageSettings.
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
|
|
203 |
} else {
|
204 |
-
gigyaFunctions.
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
}
|
206 |
|
207 |
}
|
101 |
|
102 |
gigyaFunctions.RaaS.loginScreens = function (event) {
|
103 |
var params = gigyaMageSettings.RaaS,
|
104 |
+
jsonParams = {"screenSet": params.WebScreen, "startScreen": params.LoginScreen};
|
105 |
if (typeof params.mobileScreenSet != 'undefined') {
|
106 |
jsonParams.mobileScreenSet = params.MobileScreen;
|
107 |
}
|
122 |
if (typeof params.mobileScreenSet != 'undefined') {
|
123 |
jsonParams.mobileScreenSet = params.MobileScreen;
|
124 |
}
|
125 |
+
if ((!params.override_links) && (params.raas_register_div_id.length > 0)) {
|
126 |
+
jsonParams.containerID = params.raas_register_div_id;
|
127 |
gigya.accounts.showScreenSet(jsonParams);
|
128 |
} else {
|
129 |
if (event) {
|
190 |
gigyaFunctions.RaaS.profileScreens();
|
191 |
}
|
192 |
gigyaFunctions.RaaS.accountEmbed();
|
193 |
+
if (typeof gigyaScreenSets !== 'undefined' && gigyaScreenSets.length > 0) {
|
194 |
+
gigyaScreenSets.forEach(function (params, dx) {
|
195 |
+
gigya.accounts.showScreenSet(params);
|
196 |
+
|
197 |
+
})
|
198 |
+
}
|
199 |
};
|
200 |
|
201 |
gigyaFunctions.RaaS.syncSession = function () {
|
202 |
gigya.accounts.getAccountInfo({
|
203 |
"callback": function (response) {
|
204 |
gigyaFunctions.RaaS.loggedIn = response.errorCode === 0;
|
205 |
+
if (gigyaMageSettings.RaaS.session_lead == 'magento') {
|
206 |
+
if (gigyaMageSettings.magentoStatus === "false" && gigyaFunctions.RaaS.loggedIn) {
|
207 |
+
gigya.accounts.logout();
|
208 |
+
} else {
|
209 |
+
gigyaFunctions.init();
|
210 |
+
}
|
211 |
} else {
|
212 |
+
if (gigyaMageSettings.magentoStatus === "true" && !gigyaFunctions.RaaS.loggedIn) {
|
213 |
+
gigyaFunctions.logout({"source": "sync"});
|
214 |
+
} else if (gigyaMageSettings.magentoStatus === "false" && gigyaFunctions.RaaS.loggedIn) {
|
215 |
+
gigyaFunctions.RaaS.login(response);
|
216 |
+
} else {
|
217 |
+
gigyaFunctions.init();
|
218 |
+
}
|
219 |
}
|
220 |
|
221 |
}
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Gigya_Socialize</name>
|
4 |
-
<version>3.2.
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
@@ -10,10 +10,10 @@
|
|
10 |
<description>Create an immersive and completely social shopping experience with Gigya's Magento Integration Cartridge. Gigya's social technology combines the core elements that power ecommerce - product awareness and discovery coupled with customer acquisition and loyalty - into a comprehensive set of features and services that are designed to keep customers engaged as well as increase shopping cart conversions while on Magento websites.
|
11 |
Gigya works with more than 600 enterprises, including 44% of the Comscore top 100 U.S. web properties, and reaches more than 1.5 billion users per month. Our platform extracts the real value from social networks, empowering online businesses to attract, engage, and understand users like never before.</description>
|
12 |
<notes>http://developers.gigya.com/display/NEX/Change+Log+-+Magento+1.x</notes>
|
13 |
-
<authors><author><name>Yaniv Aran-Shamir</name><user>Gigya</user><email>
|
14 |
-
<date>2016-
|
15 |
-
<time>
|
16 |
-
<contents><target name="magecommunity"><dir name="Gigya"><dir name="Social"><dir name="Block"><dir name="Adminhtml"><file name="RaasTitles.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Gigya_Socialize</name>
|
4 |
+
<version>3.2.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Create an immersive and completely social shopping experience with Gigya's Magento Integration Cartridge. Gigya's social technology combines the core elements that power ecommerce - product awareness and discovery coupled with customer acquisition and loyalty - into a comprehensive set of features and services that are designed to keep customers engaged as well as increase shopping cart conversions while on Magento websites.
|
11 |
Gigya works with more than 600 enterprises, including 44% of the Comscore top 100 U.S. web properties, and reaches more than 1.5 billion users per month. Our platform extracts the real value from social networks, empowering online businesses to attract, engage, and understand users like never before.</description>
|
12 |
<notes>http://developers.gigya.com/display/NEX/Change+Log+-+Magento+1.x</notes>
|
13 |
+
<authors><author><name>Yaniv Aran-Shamir</name><user>Gigya</user><email>cms@gigya-inc.com</email></author></authors>
|
14 |
+
<date>2016-11-08</date>
|
15 |
+
<time>08:56:49</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Gigya"><dir name="Social"><dir name="Block"><dir name="Adminhtml"><file name="RaasTitles.php" hash="6c228a5d9c99fe0b57ed8553340658c2"/><file name="Secret.php" hash="693844e8c51169a232264e447e25aace"/><file name="SiteSecret.php" hash="da5b0bf7226b4bb9bc3f72e2ddeef5ce"/><file name="Version.php" hash="8a6adb0c33e9a34314bd2392a336513f"/></dir><file name="Emailform.php" hash="451afdbee559b74a3b4678c908cc7353"/><file name="Followbar.php" hash="5d92bea0bfc1e02c24983365b85a5756"/><dir name="Gamification"><file name="Notifications.php" hash="da74d7954a5d0a19eeeb5bb747f95d36"/><file name="Plugins.php" hash="ac54c592405dd3b53f884824c1ef9f2a"/></dir><dir name="Html"><file name="Head.php" hash="d520bcb49b91bc9575d800744ce0f188"/></dir><file name="Login.php" hash="eb404ea02f1e1f4e463d71ac34ff2c00"/><file name="Logout.php" hash="a485a9dccb9bad1f4b50881420e2e548"/><file name="MainScript.php" hash="c3410e0a3f04f814ec1bafa352c29ae5"/><file name="Ordersharebar.php" hash="be5b91cd0d77389818b2303ff2242378"/><dir name="Raas"><file name="ScreenSets.php" hash="3e75e1814f575d19d28e29dd8e028d8b"/></dir><file name="Ratings.php" hash="98b4b1afcfeb6ddc4075779ee29c5e60"/><file name="Reviews.php" hash="75164d9beebad9aa3fb6a5cc0a30a2ea"/><file name="Share.php" hash="a18241aa6f84b8250b9f0084bdd47fcd"/><dir name="Template"><file name="Links.php" hash="68879a12717a23a684be7dffaa79e108"/></dir></dir><dir name="Helper"><file name="Data.php" hash="f9c72abde8fed8adb7893dc49279bbf2"/><dir name="FieldMapping"><file name="Conf.php" hash="8d38fb5bb94ddcef4905041849160ce1"/><file name="ConfItem.php" hash="045dd27a84cd484483831c55df158151"/><file name="GigyaUpdater.php" hash="042c84389603644f1272dd2d04061e3c"/><file name="MagentoUpdater.php" hash="84fd23f4c56fa76089eb5860c8f68f2e"/><file name="Transformers.php" hash="d5f0af1d48c99dad17e010bdce8e4211"/><file name="Updater.php" hash="c7d30dbc8e08ba1c74555188e188219e"/></dir></dir><dir name="Model"><dir name="Cart"><file name="Observer.php" hash="d8c4b821dcaea049496fec2f0b5f07ac"/></dir><dir name="Config"><dir name="Backend"><file name="ApiKey.php" hash="e8eada2d2ebded523920821a14e3be41"/><file name="Counters.php" hash="218aae8bf0497bc25aaec94195c0ab02"/><file name="Gm.php" hash="a2ba7beaf07c4d7bc5e8736f5b7d3272"/><file name="RaasScreens.php" hash="7e63a1afedf241ebc0324dc3ab119083"/><file name="Secret.php" hash="3fa27a1830afa9ef4bf2faf5c6793386"/><file name="UserMode.php" hash="495bae3bff51b35582e75e826ebdbd0d"/></dir><dir name="Source"><file name="AllwaysShare.php" hash="a49379230b6b4478725c06d2d0421a5c"/><file name="Buttons.php" hash="1fcdc7bd6c48d5cf51839f90e7c1b350"/><file name="CountType.php" hash="6f32a7ddbdeef69c26f25a8fbe8dffd8"/><file name="Counts.php" hash="fbf37735c569c7615abc8e8db073bfea"/><file name="Datacenter.php" hash="f99a9ef73db512b5e7d1fdd89f7b4888"/><file name="Imageb.php" hash="e148c69185fbb8869c1acabcd8e9379e"/><file name="Languages.php" hash="a8bb2abb10d683e99d183399c9705c20"/><file name="LanguagesNoAuto.php" hash="7f0d51e4e1c2d48f636bd8c729c1d4b6"/><file name="Layout.php" hash="4b342404359e3e2a02d11f0d0dabb13c"/><file name="Lead.php" hash="cafe69246424376efdf15b53bcd284fc"/><file name="Leaderboard.php" hash="b2f631e4d79fe70fe9f2d0c5f02247fe"/><file name="LoginModes.php" hash="5444715102f83758ebf193b8343fb28b"/><file name="Loginb.php" hash="9edf0f63a54fd1c5828efcd4ca0550cf"/><file name="Privacy.php" hash="74252005f3bd4d8189b4d6b029a2f21e"/><file name="Scope.php" hash="b0e7836ce30e46147c62de136f79660f"/></dir></dir><dir name="Customer"><file name="Observer.php" hash="d6ff49981eca517b710cb7210f1221f2"/></dir></dir><dir name="controllers"><file name="AccountController.php" hash="0f474f96481b49b4523fb0d3bd0b1f87"/><file name="AdminController.php" hash="740511268dd5a6bb032ef68450b5b8dd"/><file name="LoginController.php" hash="9286a68af5f6472aff9d600de951e001"/><file name="ReviewsController.php" hash="d0e0ecc161ed4cd85c49378939c54238"/></dir><dir name="data"><dir name="Gigya_Social_setup"><file name="data-upgrade-3.1.2-3.2.0.php" hash="fa5bf5f567179022821d34cfa9164fa8"/></dir></dir><dir name="etc"><file name="config.xml" hash="1c8a09573744bce980c65edc767bdf7f"/><file name="mappings.json" hash="5cc558af209752e9bd521bdb7d6620ec"/><file name="system.xml" hash="28cbcd2b4ded589f84064bc59c22e5c5"/></dir><dir name="sdk"><file name="GSSDK.php" hash="f8f8f495a79b5305eb8c532ecbd780c5"/><file name="cacert.pem" hash="1fb001624232803a8697350b6500a1e1"/><file name="gigyaCMS.php" hash="41ffa23e07ffc99f36c88ff980f59cb7"/></dir><dir name="sql"><dir name="Gigya_Social_setup"><file name="mysql4-install-3.0.0.php" hash="44d9705097928a4530644d00940982f6"/><file name="mysql4-upgrade-2.0.3-3.0.0.php" hash="44d9705097928a4530644d00940982f6"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="gigya"><file name="activityfeed.phtml" hash="c8c6851828c473a757c986e206eac4b8"/><file name="comments.phtml" hash="bbc5eaa0c94d4ac7b8e2cbe6da5ea991"/><dir name="dashboard"><file name="info.phtml" hash="01786401a2d845c0f987257d55fc823a"/></dir><file name="followbar.phtml" hash="074d092f23f42513e18ba4b7ce7d0c93"/><dir name="form"><file name="emailForm.phtml" hash="c96d44c1435d40a5fe199facd1e06452"/><file name="login.phtml" hash="4caa3aa9df51a326707b801a5f75107e"/><file name="mini.login.phtml" hash="a4612e9f7105e835fe3932a196da69ea"/></dir><file name="gamification.phtml" hash="e79a8d85513125c5230301fe5dcb9c5d"/><dir name="login"><file name="link_accounts.phtml" hash="15a7e0fdac055d46a5d718b453747cda"/><file name="social_login.phtml" hash="44b6c5ede7f218f058289489be45ca31"/><file name="social_login_login_page.phtml" hash="045359d467df96de18a8e00beb13ab19"/></dir><dir name="raas"><dir name="onepage"><file name="screenset.phtml" hash="07373daa1580157d84d1f50e57732778"/></dir><file name="screenset.phtml" hash="170db083a56e76720c5b72d18856519e"/></dir><dir name="ratings"><file name="summary.phtml" hash="2aed5a73bd18a84d7d2d48001d497043"/><file name="summary_short.phtml" hash="f5b1c68cad24f236017f65588f3449cc"/></dir><file name="ratings.phtml" hash="9d193c00bc415ee4ab4095e5e3f393c4"/><dir name="share"><file name="ordersharebar.phtml" hash="a98bc14f1cc62f0b7029e72c1c2b3668"/><file name="reactions.phtml" hash="f5abcc69935c0f21d5eb9077d226cf9f"/><file name="sharebar.phtml" hash="96373d45127a16370fbc4ec55efc57d5"/></dir></dir></dir><dir name="layout"><file name="aagigya.xml" hash="94ea5dc3b7762f6d842260ebe877a6de"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="gigya_admin.xml" hash="2da57a0e2d9f61f9a770b406e2db2e63"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gigya_Social.xml" hash="e5f95ec2941faac5d4ed834f8c1c8b15"/></dir></target><target name="mageweb"><dir name="js"><dir name="gigya"><file name="admin.js" hash="e71b2c52a648ede9f3adb6d85069fa2e"/><file name="gigyaMagento.js" hash="c59982d730b8acf8e6f50682564aa5fa"/><dir name="json"><file name="jsonlint.js" hash="acea01bc9607caf723cfe454edc00d7c"/><file name="validateJson.js" hash="7837f11354307ab1a0864e61db9fed95"/></dir><file name="onepage_raas.js" hash="e163a4ee6581b8f32c7af2c6fee08a5c"/></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
19 |
</package>
|