akeeba / sociallogin

Joomla!™ login and user account creation with Facebook, Google, GitHub etc social media accounts
29 stars 9 forks source link

Joomla cache and social login problem #73

Closed GabrielAngio2021 closed 3 years ago

GabrielAngio2021 commented 3 years ago

Joomla! 3.9.26 - HTTPS - PHP | 7.3.27 - Akeeba Social Login package 3.2.7

With the cache disabled, I get the plugin to work correctly to display the site as a registered user With the cache activated I have to force the reload of the browser, otherwise it returns to the previous page. I have tried to exclude com_users in Plugins: System - Cache, but it still doesn't work.

I hope you were able to solve your problem with the NAS Thank you

nikosdion commented 3 years ago

I cannot reproduce this issue. I have tried various combinations of the three states of caching in Global Configuration and the System - Cache plugin's options.

FWIW SocialLogin never goes through com_users so adding that to the System - Cache plugin is futile. SocialLogin only goes through com_ajax to call its own code which validates the social network login and logs the user in. Then the user is redirected to the page you started the login from.

GabrielAngio2021 commented 3 years ago

I see If I want to redirected the user into other page. I can customize the redirection, once the user logged in?

nikosdion commented 3 years ago

Yes, but it does require doing a template override for your login module or your login page as described in the “Integrating with template overrides” documentation page.

The reason is that Joomla does not let us know what is the redirection URL set up in the login module or login page. There is really no way for us to read it unless we replicated the code of the login module or page. While this would be doable (but not very stable!) for core Joomla, it's outright impossible to do with all the various third party modules. Doing a template override is the One True Joomla! Way of running custom code in the context of a module or component so we opted for this solution.

Please do remember that in this case you will need to change the plugin options so it does NOT try to inject buttons in the login modules and login pages of your site. The reason is that you'll be handling this manually, in your template overrides.

GabrielAngio2021 commented 3 years ago

Let's see if I understand correctly, Social login should redirect me to the page configured in the module or in the access menu item. Well it doesn't. Access pages: https://nataliaygabriel.com/usuario (module) https://nataliaygabriel.com/login-register (Menu) If I log in with the joomla user system, it redirects me correctly to https://nataliaygabriel.com/articulos-exclusivos-para-miembros

If I log in with Social Login, it returns me to https://nataliaygabriel.com/# or https://nataliaygabriel.com/login-register# https://nataliaygabriel.com/usuario#

once again I take the opportunity to thank you for your dedication

nikosdion commented 3 years ago

No, I said the exact opposite and I was very clear in my choice of words and phrasing. Let's try this again.

UNLESS you do a template override, it CAN NOT redirect you to the page configured in the login module or login page BECAUSE Joomla does not let us see if such a URL is configured or what it is. THEREFORE you need to do template overrides per the documentation which DOES allow you to run custom in the context of the login module or component THEREFORE allowing you to pass the otherwise inaccessible redirection URL.

Please read my replies and the documentation page I link you to more carefully.

GabrielAngio2021 commented 3 years ago

I did the template overwrite, and it takes it correctly. But when I add the code <? php if (class_exists ('Akeeba \ SocialLogin \ Library \ Helper \ Integrations')) echo \ Akeeba \ SocialLogin \ Library \ Helper \ Integrations :: getSocialLoginButtons ()?> Stop working

the System plugin - Akeeba Social Login Frontend Login Modules' Names ---- None Add buttons to login page ------- No

Attached override code

`<?php /**

defined('_JEXEC') or die;

JLoader::register('UsersHelperRoute', JPATH_SITE . '/components/com_users/helpers/route.php');

JHtml::('behavior.keepalive'); JHtml::('bootstrap.tooltip');

?>

get('pretext')) : ?>

get('pretext'); ?>

get('usetext', 0)) : ?>
get('usetext', 0)) : ?>
1) : ?>
get('usetext', 0)) : ?>
    get('allowUserRegistration')) : ?>
get('posttext')) : ?>

get('posttext'); ?>

` is there something else i'm doing wrong?

nikosdion commented 3 years ago

You added too many spaces. This is WRONG: <? php if ( class_exists ( 'Akeeba \\ SocialLogin \\ Library \\ Helper \\ Integrations' )) echo \ Akeeba \ SocialLogin \ Library \ Helper \ Integrations :: getSocialLoginButtons () ?>

This is how it's meant to be written (note there are no spaces between the backslashes):

<? php  if ( class_exists ( 'Akeeba\\SocialLogin\\Library\\Helper\\Integrations' )) echo \Akeeba\SocialLogin\Library\Helper\Integrations :: getSocialLoginButtons () ?>

Also note two more things:

Please read the documentation page I linked you to again. I have a copy & paste example.

GabrielAngio2021 commented 3 years ago

Thank you

the problem was that I was translating the github.com/akeeba/sociallogin with google translate and it adding spaces in the code

finally it worked like this: ?php if (class_exists('Akeeba\\SocialLogin\\Library\\Helper\\Integrations')) echo \Akeeba\SocialLogin\Library\Helper\Integrations::getSocialLoginButtons () ?>

Now I am trying to get the redirect to work. If I insert this code instead of the other ?php if (class_exists('Akeeba\\SocialLogin\\Library\\Helper\\Integrations')) echo \Akeeba\SocialLogin\Library\Helper\Integrations::getSocialLoginButtons($this->successURL) ?>

stops working. I am using the Joomla login module

Assuming I want to redirect to: https://nataliaygabriel.com/articulos-exclusivos-para-miembros

Should I change ($ this-> successURL) to another code? How do I obtain?

nikosdion commented 3 years ago

With the default Joomla 3 mod_login you can put the following under the Remember Me DIV:

        <div id="form-login-submit--<?= $random ?>" class="control-group">
            <div style="width:90%">
                <button type="submit" tabindex="0" name="Submit"
                        class="btn btn-primary akeeba-sociallogin-button">
                    <span class="icon icon-user"></span>
                    <small>Login with</small> account
                </button>
                <?php if (class_exists('Akeeba\\SocialLogin\\Library\\Helper\\Integrations')) echo \Akeeba\SocialLogin\Library\Helper\Integrations::getSocialLoginButtons(base64_decode($return)) ?>
            </div>
        </div>

The $return variable comes from the module file itself.

For Joomla 3's com_users you can override default_login.php and replace its login button with

            <div class="control-group">
                <div class="controls">
                    <!-- nicholas: start -- Social Login buttons -->
                    <button type="submit" tabindex="0" name="Submit" class="btn btn-default akeeba-sociallogin-button akeeba-sociallogin-button-email">
                        <span class="icon-social-email"></span>
                        <small><?php echo JText::_('JLOGIN'); ?></small>
                    </button>
                    <?php if (class_exists('Akeeba\\SocialLogin\\Library\\Helper\\Integrations')) echo \Akeeba\SocialLogin\Library\Helper\Integrations::getSocialLoginButtons($return) ?>

                    <!-- nicholas: end -- Social Login buttons -->
                </div>
            </div>

The $return variable in this case comes from the top of the file.

GabrielAngio2021 commented 3 years ago

Hello The topic I started on social login has been closed and disappeared. I wanted to let you know that I'm still working on it. With the code that you sent me (Thank you so much). I was able to redirect to the page I wanted after logging. But for that I had to do 2 things:

  1. Browser cahe: In the system cache PLUGIN - enable the browser cache, but exclude the menu item that contains the registration and login module.

  2. Sistem global configuration: This is my real problem. It only works with the system cache disabled. I think there is a problem with the K2. Because in the error_log when I activate the cahe, it marks an error

/plugins/system/k2/k2.php

in this line

$getK2CacheHeaders = json_decode(trim($getK2CacheHeaders[1])); if (is_object($getK2CacheHeaders)) { JResponse::allowCache(true); foreach ($getK2CacheHeaders as $type => $value) { JResponse::setHeader($type, $value, true); }

Please forgive my delay in this answer and thank you very much for the code you gave me.

Gabriel Angio www.nataliaygabriel.com

[image: Mailtrack] https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& Remitente notificado con Mailtrack https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& 24/05/21 09:02:40 a. m.

El lun, 24 may 2021 a las 0:29, Nicholas K. Dionysopoulos (< @.***>) escribió:

Closed #73 https://github.com/akeeba/sociallogin/issues/73.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/akeeba/sociallogin/issues/73#event-4784266500, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATZ5ISGDDWDDGM2FNEJLGOTTPHB3DANCNFSM43RKC56A .

nikosdion commented 3 years ago

As I already said, I cannot reproduce your issue. In other words, your problem is not a bug in our software.

I have not used K2 since early 2011. It would appear that its code has also not been updated since then! JResponse is an obsolete class, removed around 2013. In any case I can't offer support for third party code, more so for third party code that seems to be out of sync with modern Joomla by nearly a decade.

So, I'm sorry that you are experiencing a problem but, not to put too fine a point on it, it's not a bug therefore it's not our problem. I will be locking this issue since as it's explicitly stated we do not offer end user support, especially for issues which have nothing to do with our software.