oneall / social-login-prestashop

Social Login for PrestaShops allows your users to login and register with 25+ social networks. It is very easy to install and helps increasing the user registration and conversion rates of your shop by simplifying the sign up process for new users.
http://docs.oneall.com/plugins/guide/social-login-prestashop/
87 stars 75 forks source link

sometimes after login it doesnt redirect user back to site #7

Closed michaelhjulskov closed 9 years ago

michaelhjulskov commented 9 years ago

Hi there Thanks for a great code and module. I have installed it on several prestashops.

I have experienced an issue though and I suspect issue to be on oneallsocial site.

After login i get stuck with this message and a blank screen "You have logged in with Facebook Please wait, you are being redirected ..." But that form isnt submitted onload, or something wrong is happening there.

If I leave it there a minute or so, it times out and ends on http://www.myshopname.com:62455/opc it should just redirect to http://www.myshopname.com/opc

any clue?

Thanks :)

SchlesserClaude commented 9 years ago

Hello,

please refresh your PrestaShop cache like this: http://docs.oneall.com/plugins/guide/social-login-prestashop/#3c

And then go to the Social Login setup in your PrestaShop admin area and click on the "Autodetect" and "Verify" buttons. Both tests must display a green success message.

michaelhjulskov commented 9 years ago

Hi :-) i did All that several times and im sure everything is okay. Also Tried various settings combinations.

michaelhjulskov commented 9 years ago

It works fine when I come from the login page but it have this issue when coming from my checkout page..

when i land on the "You have logged in with xxx Please wait, you are being redirected ..." if i refresh it will submit onload and redirect me back - logged in. So I always get logged in correctly, but I dont get redirected.

michaelhjulskov commented 9 years ago

Been doing a bit of bug tracking I added some logs inside this :

public static function get_current_url ()
{
    //Get request URI - Should work on Apache + IIS
    $request_uri = (isset ($_SERVER ['REQUEST_URI']) ? $_SERVER ['REQUEST_URI'] : $_SERVER ['PHP_SELF']);
    $request_protocol = (self::is_https_on () ? 'https' : 'http');
    $request_host = (isset ($_SERVER ['HTTP_X_FORWARDED_HOST']) ? $_SERVER ['HTTP_X_FORWARDED_HOST'] : (isset ($_SERVER ['HTTP_HOST']) ? $_SERVER ['HTTP_HOST'] : $_SERVER ['SERVER_NAME']));

    // Make sure we strip $request_host so we got no double ports un $current_url
    $request_host = preg_replace('/:[0-9]*$/', '', $request_host);

    //We are using a proxy
    if (isset ($_SERVER ['HTTP_X_FORWARDED_PORT']))
    {
        // SERVER_PORT is usually wrong on proxies, don't use it!
        $request_port = intval ($_SERVER ['HTTP_X_FORWARDED_PORT']);
    }
    //Does not seem like a proxy
    elseif (isset ($_SERVER ['SERVER_PORT']))
    {
        $request_port = intval ($_SERVER ['SERVER_PORT']);
    }

    // Remove standard ports
    $request_port = (!in_array ($request_port, array (80, 443)) ? $request_port : '');

    //Build url
    $current_url = $request_protocol . '://' . $request_host . ( ! empty ($request_port) ? (':'.$request_port) : '') . $request_uri;
    PrestaShopLogger::addLog('oneallsocial line '.__LINE__.' '.$current_url, 1, null, null, null, true);
    //Done
    return $current_url;
}

and I got this in my log: oneallsocial line 825 http://www.myshopname.com:62455/opc

is this indicating some issue?

SchlesserClaude commented 9 years ago

Are you using a proxy like for example nginx?

michaelhjulskov commented 9 years ago

Yes sir :)

SchlesserClaude commented 9 years ago

Could you add this to the server {...} section of your nginx configuration?

proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $http_x_forwarded_host;

That should fix the error.

michaelhjulskov commented 9 years ago

im total newb with that kindathing i think i run lighttpd and on my server I have lighttpd.conf could that be the file I should add somthing to?

SchlesserClaude commented 9 years ago

In this case it might be easier to patch the plugin:

Please replace this:

// Remove standard ports
$request_port = (!in_array ($request_port, array (80, 443)) ? $request_port : '');

By

// Remove standard ports
$request_port = (!in_array ($request_port, array (80, 443, 62455)) ? $request_port : '');
michaelhjulskov commented 9 years ago

ahh i thought of doing that actually :) Thanks a lot :+1:

Finally fixed - it took me days and nights to find this :)

SchlesserClaude commented 9 years ago

Good that it's fixed now ;)

michaelhjulskov commented 9 years ago

By the way you should use {l s='Confirm'} in stead of "Confirm" in oneallsociallogin.tpl <button name="submit" id="submit" type="submit" class="btn btn-default button button-medium"><span>{l s='Confirm'}<i class="icon-chevron-right right"></i></span></button>

SchlesserClaude commented 9 years ago

Thank you! Done!