Skip to content

Commit

Permalink
Merge pull request #289 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
chuccv authored Feb 16, 2024
2 parents 27d9ee0 + 54cc1a7 commit 5f08a79
Show file tree
Hide file tree
Showing 15 changed files with 1,780 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Controller/Popup/Forgot.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Magento\Framework\Exception\SecurityViolationException;
use Magento\Framework\Validator\ValidateException;
use Magento\Framework\Validator\ValidatorChain;
use Magento\Framework\Validator\EmailAddress;
use Mageplaza\SocialLogin\Helper\Data;

/**
Expand Down Expand Up @@ -142,7 +143,7 @@ public function execute()
$email = (string) $this->getRequest()->getPost('email');

if ($email) {
if (!ValidatorChain::is($email, 'EmailAddress')) {
if (!ValidatorChain::is($email, EmailAddress::class)) {
$this->session->setForgottenEmail($email);
$result['message'][] = __('Please correct the email address.');
}
Expand Down
22 changes: 22 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,26 @@ public function isCheckMode($storeId = null)
{
return $this->getConfigGeneral('check_mode', $storeId) && $this->getPopupLogin();
}

/**
* @param string $code
* @param null $storeId
*
* @return array|mixed
*/
public function getConfigGoogleRecaptcha($code = '', $storeId = null)
{
return $this->getConfigValue('googlerecaptcha' . $code, $storeId);
}

/**
* @param null $storeId
*
* @return bool
*/
public function isEnabledGGRecaptcha($storeId = null)
{
return $this->getConfigGoogleRecaptcha('/general/enabled', $storeId)
&& $this->getConfigGoogleRecaptcha('/frontend/enabled', $storeId);
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "mageplaza/magento-2-social-login",
"description": "Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps",
"require": {
"mageplaza/module-core": "^1.5.3",
"mageplaza/module-core": "^1.5.6",
"hybridauth/hybridauth": "^3.8.2"
},
"require-dev": {
"roave/security-advisories": "dev-master"
},
"type": "magento2-module",
"version": "4.1.10",
"version": "4.1.11",
"license": "proprietary",
"authors": [
{
Expand Down
126 changes: 126 additions & 0 deletions view/frontend/layout/hyva_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ProductLabels
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Mageplaza_SocialLogin::css/style_hyva.css" />
</head>

<update handle="hyva_modal"/>
<update handle="hyva_form_validation"/>
<body>
<referenceBlock name="head.additional">
<block class="Mageplaza\SocialLogin\Block\Css" name="social_login_custom_style" ifconfig="sociallogin/general/enabled" template="Mageplaza_SocialLogin::css.phtml"/>
</referenceBlock>
<referenceContainer name="content">
<block class="Mageplaza\SocialLogin\Block\Popup" name="modal-dialog" template="Mageplaza_SocialLogin::hyva/header/modal.phtml">
<block class="Mageplaza\SocialLogin\Block\Popup\Social" name="social-login-popup-authentication-social" as="popup.authentication.social" template="Mageplaza_SocialLogin::hyva/popup/form/social_buttons.phtml"/>
<block class="Mageplaza\SocialLogin\Block\Popup" name="social-login-popup-email" before="-" as="popup.email" template="Mageplaza_SocialLogin::hyva/popup/form/email.phtml"/>
<block class="Mageplaza\SocialLogin\Block\Form\Login" name="social-login-popup-authentication" as="popup.authentication" template="Mageplaza_SocialLogin::hyva/popup/form/authentication.phtml">
<container name="social.login.form.additional.info.login" as="form_additional_info">
<block class="Magento\Captcha\Block\Captcha" name="social-login-captcha" as="login.captcha" after="-">
<action method="setFormId">
<argument name="formId" xsi:type="string">user_login</argument>
</action>
<action method="setImgWidth">
<argument name="width" xsi:type="string">230</argument>
</action>
<action method="setImgHeight">
<argument name="width" xsi:type="string">50</argument>
</action>
</block>
</container>
</block>
<block class="Mageplaza\SocialLogin\Block\Form\Register" name="social-login-popup-create" as="popup.create" template="Mageplaza_SocialLogin::hyva/popup/form/create.phtml">
<container name="social.login.form.additional.info.create" as="form_additional_info">
<block class="Magento\Captcha\Block\Captcha" name="social-create-captcha" as="create.captcha" after="-">
<action method="setFormId">
<argument name="formId" xsi:type="string">user_create</argument>
</action>
<action method="setImgWidth">
<argument name="width" xsi:type="string">230</argument>
</action>
<action method="setImgHeight">
<argument name="width" xsi:type="string">50</argument>
</action>
</block>
</container>
</block>
<block class="Magento\Framework\View\Element\Template" name="social-login-popup-forgot" as="popup.forgot" template="Mageplaza_SocialLogin::hyva/popup/form/forgot.phtml">
<container name="social.login.form.additional.info.forgot" as="form_additional_info">
<block class="Magento\Captcha\Block\Captcha" name="social-forgot-password-captcha" as="forgot.captcha" after="-">
<action method="setFormId">
<argument name="formId" xsi:type="string">user_forgotpassword</argument>
</action>
<action method="setImgWidth">
<argument name="width" xsi:type="string">230</argument>
</action>
<action method="setImgHeight">
<argument name="width" xsi:type="string">50</argument>
</action>
</block>
</container>
</block>
</block>

</referenceContainer>
<referenceBlock name="customer.header.sign.in.link">
<action method="setTemplate">
<argument name="template" xsi:type="string">Mageplaza_SocialLogin::hyva/header/link/sign-in.phtml</argument>
</action>
</referenceBlock>
<referenceBlock name="customer.header.register.link">
<action method="setTemplate">
<argument name="template" xsi:type="string">Mageplaza_SocialLogin::hyva/header/link/register.phtml</argument>
</action>
</referenceBlock>
<referenceBlock name="authentication-popup">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="authenticationPopup" xsi:type="array">
<item name="children" xsi:type="array">
<item name="social-buttons" xsi:type="array">
<item name="component" xsi:type="string">Mageplaza_SocialLogin/js/view/social-buttons</item>
<item name="displayArea" xsi:type="string">before</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>


<referenceBlock name="social-login-popup-authentication-social-login" >
<action method="setTemplate">
<argument name="template" xsi:type="string">Mageplaza_SocialLogin::hyva/form/social.phtml</argument>
</action>
</referenceBlock>

<referenceBlock name="social-login-popup-authentication-social-create" >
<action method="setTemplate">
<argument name="template" xsi:type="string">Mageplaza_SocialLogin:hyva/form/social.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
90 changes: 90 additions & 0 deletions view/frontend/templates/hyva/form/social.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_SocialLogin
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

$availableSocials = $block->getAvailableSocials();
$childBlock = $block->getChildBlock('request.info');

if ($block->canShow() && sizeof($availableSocials)):
?>
<div class="block social-login-authentication-channel account-social-login">
<div class="block-content">
<?php foreach ($availableSocials as $key => $social): ?>
<div class="actions-toolbar social-btn social-btn-actions-toolbar <?= $key ?>-login">
<a class="btn btn-block btn-social btn-<?= $block->getBtnKey($key) ?>"
data-mage-init='{"socialProvider": {"url": "<?= $social['login_url'] ?>", "label": "<?= __('Login By %1', $social['label']) ?>"}}'
onclick='clickLoginSocial("<?= $social['login_url'] ?>","<?= $social['label'] ?>")'
>
<span class="fa fa-<?= $block->getBtnKey($key) ?>"></span>
<?= __('Sign in with %1', $social['label']) ?>
</a>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if ($childBlock && $childBlock->isRequireMoreInfo()): ?>
<div id="social-login-popup" class="white-popup mfp-with-anim mfp-hide"
data-mage-init='{"Mageplaza_SocialLogin/js/popup":<?= $childBlock->getFormParams() ?>}'>
<?= $block->getChildHtml('request.info') ?>
</div>
<?php endif; ?>
<style type="text/css">
.request-popup{
overflow-y: unset;
max-width: 800px;
left: 30%;
}
.request-popup .modal-header{
padding: 0;
}
.request-popup .modal-header button.action-close{
color: white;
z-index: 100;
}
.request-popup .modal-content{
padding: 0;
}
</style>
<script type="text/javascript">
function getPopupParams(w, h, l, t) {
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft;
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop;
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth;
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22);
var width = w ? w : 500;
var height = h ? h : 420;
var left = l ? l : parseInt(screenX + ((outerWidth - width) / 2), 10);
var top = t ? t : parseInt(screenY + ((outerHeight - height) / 2.5), 10);

return (
'width=' + width +
',height=' + height +
',left=' + left +
',top=' + top
);
}
function clickLoginSocial(login_url, label) {
var date = new Date();
var currentTime = date.getTime();
window.open(login_url + '?' + currentTime, label, getPopupParams());
}

</script>
78 changes: 78 additions & 0 deletions view/frontend/templates/hyva/header/link/register.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_SocialLogin
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/


declare(strict_types=1);

use Hyva\Theme\Block\SortableItem;
use Hyva\Theme\Model\ViewModelRegistry;
use Hyva\Theme\ViewModel\CustomerRegistration;
use Magento\Framework\Escaper;

/** @var SortableItem $block */
/** @var Escaper $escaper */
/** @var ViewModelRegistry $viewModels */
/** @var CustomerRegistration $customerRegistration */

$customerRegistration = $viewModels->require(CustomerRegistration::class);

$label = $block->getLabel() ? $block->getLabel() : __('Create an Account');
$helperData = $this->helper(\Mageplaza\SocialLogin\Helper\Data::class);
$popupEffect = $helperData->getPopupEffect();
$popupLogin = $helperData->getPopupLogin();
?>

<?php if ($customerRegistration->isAllowed()): ?>
<?php
if ($popupLogin === 'popup_login'): ?>
<div>
<a id="<?= $escaper->escapeHtmlAttr($block->getNameInLayout()) ?>"
class="block px-4 py-2 lg:px-5 lg:py-2 hover:bg-gray-100"
href="#"
title="<?= $escaper->escapeHtmlAttr($label) ?>"
onclick="onClickRegister()"
>
<?= $escaper->escapeHtml($label) ?>
</a>
</div>
<?php else: ?>
<div>
<a id="<?= $escaper->escapeHtmlAttr($block->getNameInLayout()) ?>"
class="block px-4 py-2 lg:px-5 lg:py-2 hover:bg-gray-100"
href="<?= $escaper->escapeUrl($customerRegistration->getRegisterUrl()) ?>"
title="<?= $escaper->escapeHtmlAttr($label) ?>"
>
<?= $escaper->escapeHtml($label) ?>
</a>
</div>
<?php endif; ?>
<?php endif; ?>

<script type="text/javascript">
function onClickRegister () {
createBtn();
const modal = document.querySelector('.wrap-modal-login');
modal.classList.add('<?= $popupEffect ?>-appear');
openMyDialog();


}
</script>
Loading

0 comments on commit 5f08a79

Please sign in to comment.