diff --git a/libraries/redshop/src/Helper/Login.php b/libraries/redshop/src/Helper/Login.php
index 6a5ff7913e7..49fa8809709 100644
--- a/libraries/redshop/src/Helper/Login.php
+++ b/libraries/redshop/src/Helper/Login.php
@@ -26,6 +26,17 @@ class Login
public static function loginJoomlaRedShop($data) {
$app = \JFactory::getApplication();
$jUser = \JUserHelper::getUserId($data['email']);
+ $pluginName = substr($app->input->get('plugin'), 0, -13);
+ if (isset($pluginName) && $pluginName == 'google') {
+ $pluginName = 'google';
+ } else {
+ $pluginName = 'facebook';
+ }
+ $plugin = \JPluginHelper::getPlugin('redshop_login', $pluginName);
+ $params = json_decode($plugin->params);
+ $returnId = $params->redirectlogin;
+ $menu = \JFactory::getApplication()->getMenu();
+ $item = $menu->getItem($returnId);
if ($jUser > 0) {
$jUser = \JFactory::getUser($jUser);
@@ -46,7 +57,13 @@ public static function loginJoomlaRedShop($data) {
$redUser = \RedshopHelperUser::storeRedshopUser($data, $jUser->id);
}
- $app->redirect(\JUri::root());
+ if ($item) {
+ $link = $item->link . '&Itemid=' . $returnId;
+ } else {
+ $link = \JUri::root();
+ }
+
+ $app->redirect($link);
}
/**
diff --git a/plugins/redshop_login/facebook/element/callbackurl.php b/plugins/redshop_login/facebook/element/callbackurl.php
new file mode 100644
index 00000000000..fb3275d0a35
--- /dev/null
+++ b/plugins/redshop_login/facebook/element/callbackurl.php
@@ -0,0 +1,48 @@
+element['value']) ? '?index.php?option=com_ajax&group=redshop_login&plugin=fbLoginCallBack&format=raw' : '';
+ $readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
+ $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
+
+ $CallbackUrl = JURI::root().$task;
+
+ if(substr($CallbackUrl, -1, 1) == '/'){
+ $CallbackUrl = substr($CallbackUrl, 0, -1);
+ }
+
+ $html = '';
+
+ return $html;
+ }
+}
\ No newline at end of file
diff --git a/plugins/redshop_login/facebook/facebook.php b/plugins/redshop_login/facebook/facebook.php
index 660f01dd81a..b9a37465f6d 100644
--- a/plugins/redshop_login/facebook/facebook.php
+++ b/plugins/redshop_login/facebook/facebook.php
@@ -32,7 +32,7 @@ public function onThirdPartyLogin()
$permissions = ['email']; // Optional permissions
$linkLogin = $helper->getLoginUrl(
- \Redshop\IO\Route::_(
+ JRoute::_(
\JUri::root() . 'index.php?option=com_ajax&group=redshop_login&plugin=fbLoginCallBack&format=raw'
),
$permissions
@@ -58,7 +58,7 @@ public function onAjaxFbLoginCallBack()
$helper = $fb->getRedirectLoginHelper();
try {
- $accessToken = $helper->getAccessToken();
+ $accessToken = $helper->getAccessToken('https://dev.lacaph.com.web1.redhost.vn/index.php?option=com_ajax&group=redshop_login&plugin=fbLoginCallBack&format=raw');
} catch (\Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
$app->enqueueMessage('Graph returned an error: ' . $e->getMessage());
diff --git a/plugins/redshop_login/facebook/facebook.xml b/plugins/redshop_login/facebook/facebook.xml
index 54c6d2d45b2..817cbc2c0c1 100644
--- a/plugins/redshop_login/facebook/facebook.xml
+++ b/plugins/redshop_login/facebook/facebook.xml
@@ -18,6 +18,7 @@
facebook.php
index.html
library
+ element
@@ -32,6 +33,21 @@
type="text"
label="PLG_REDSHOP_LOGIN_FACEBOOK_APP_SECRET"
/>
+
+
diff --git a/plugins/redshop_login/facebook/language/en-GB/en-GB.plg_redshop_login_facebook.ini b/plugins/redshop_login/facebook/language/en-GB/en-GB.plg_redshop_login_facebook.ini
index 5c5748e7180..b7804f5a22b 100644
--- a/plugins/redshop_login/facebook/language/en-GB/en-GB.plg_redshop_login_facebook.ini
+++ b/plugins/redshop_login/facebook/language/en-GB/en-GB.plg_redshop_login_facebook.ini
@@ -7,3 +7,5 @@ PLG_REDSHOP_LOGIN_FACEBOOK="redSHOP Login - Facebook"
PLG_REDSHOP_LOGIN_FACEBOOK_DESC="redSHOP Login - Facebook"
PLG_REDSHOP_LOGIN_FACEBOOK_APP_ID="App Id"
PLG_REDSHOP_LOGIN_FACEBOOK_APP_SECRET="App secret"
+PLG_REDSHOP_LOGIN_GOOGLE_CALLBACK_URL="Callback url"
+PLG_REDSHOP_LOGIN_GOOGLE_LOGIN_REDIRECT="Login redirect"
diff --git a/plugins/redshop_login/google/element/callbackurl.php b/plugins/redshop_login/google/element/callbackurl.php
new file mode 100644
index 00000000000..319503469ff
--- /dev/null
+++ b/plugins/redshop_login/google/element/callbackurl.php
@@ -0,0 +1,48 @@
+element['value']) ? '?index.php?option=com_ajax&group=redshop_login&plugin=googleLoginCallBack&format=raw' : '';
+ $readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
+ $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
+
+ $CallbackUrl = JURI::root().$task;
+
+ if(substr($CallbackUrl, -1, 1) == '/'){
+ $CallbackUrl = substr($CallbackUrl, 0, -1);
+ }
+
+ $html = '';
+
+ return $html;
+ }
+}
\ No newline at end of file
diff --git a/plugins/redshop_login/google/google.php b/plugins/redshop_login/google/google.php
index 7f3f8a47c83..fe31c5a086b 100644
--- a/plugins/redshop_login/google/google.php
+++ b/plugins/redshop_login/google/google.php
@@ -39,7 +39,7 @@ public function getGoogleObject()
{
$client = new Google_Client();
- $redirectUri = \Redshop\IO\Route::_(
+ $redirectUri = JRoute::_(
\JUri::root() . 'index.php?option=com_ajax&group=redshop_login&plugin=googleLoginCallBack&format=raw'
); // URL này được Google chuyển hướng, khi người dùng đồng ý
diff --git a/plugins/redshop_login/google/google.xml b/plugins/redshop_login/google/google.xml
index c8f8732a3af..6377e8ad9a7 100644
--- a/plugins/redshop_login/google/google.xml
+++ b/plugins/redshop_login/google/google.xml
@@ -18,6 +18,7 @@
google.php
index.html
library
+ element
@@ -32,6 +33,21 @@
type="text"
label="PLG_REDSHOP_LOGIN_GOOGLE_SECRET"
/>
+
+
diff --git a/plugins/redshop_login/google/language/en-GB/en-GB.plg_redshop_login_google.ini b/plugins/redshop_login/google/language/en-GB/en-GB.plg_redshop_login_google.ini
index 73c142a27c2..4663f610c07 100644
--- a/plugins/redshop_login/google/language/en-GB/en-GB.plg_redshop_login_google.ini
+++ b/plugins/redshop_login/google/language/en-GB/en-GB.plg_redshop_login_google.ini
@@ -7,3 +7,5 @@ PLG_REDSHOP_LOGIN_GOOGLE="redSHOP Login - Google"
PLG_REDSHOP_LOGIN_GOOGLE_DESC="redSHOP Login - Google"
PLG_REDSHOP_LOGIN_GOOGLE_CLIENT_ID="Client id"
PLG_REDSHOP_LOGIN_GOOGLE_SECRET="Secret"
+PLG_REDSHOP_LOGIN_GOOGLE_CALLBACK_URL="Callback url"
+PLG_REDSHOP_LOGIN_GOOGLE_LOGIN_REDIRECT="Login redirect"
\ No newline at end of file