akeeba / sociallogin

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

Login redirect is not working when using Google #79

Closed Muhammad-Umaar closed 2 years ago

Muhammad-Umaar commented 2 years ago

Login using Google is working fine except we cannot use redirect feature from the 'Login Form' menu.

Login redirect to 'Edit User Profile' profile is not working using Google login. Redirect is working well if login using default Joomla user login form.

Create login menu, select 'Login form'. Under 'Menu Item Login Redirect', select 'Edit User Profile'. From frontend, from newly created menu, login using Google.

Expecting result is when login using Google, it will redirect user to an 'Edit User Profile' page.

Joomla! version : Joomla! 3.10.2 PHP version : 7.4.23 Am I using HTTPS : Yes Server Operating System**: Linux My device's Operating System : Windows, iOS, Android... My device's Operating System version : Windows 10 Browser: Chrome Browser version: Version 94.0.4606.81

nikosdion commented 2 years ago

The menu item redirection cannot work on Joomla 3. This is a limitation of Joomla itself. It does not support third party login buttons. What we are doing is a hack way which involves JavaScript to place our social login buttons in the vicinity of the module, hopefully making it look like that they are part of the login module. In fact, they are not part of the module and they do not know of the redirection information you have specified in the module. Same for the user login page.

This issue is solved on Joomla 4 which supports third party login buttons natively, thanks to the feature I contributed for WebAuthn login.

Since Joomla 3 is on its way out I have stopped developing new features for it. Solving this issue would require developing a custom login module at the very least which was never a very good solution, hence it was never implemented. Knowing that Joomla 4 already solves this issue there is no reason to reinvent the wheel for the older CMS version which will be discontinued in less than 2 years.

Muhammad-Umaar commented 2 years ago

I see...thank you for clarification @nikosdion 🥇

sakiss commented 2 years ago

Hi @nikosdion

I am facing the exact same issue in Joomla 4. It ignores the set redirect page in the login menu item, for both my social login plugins (Google, Facebook). It always redirects to the login/logout page after logging in.

Any idea?

nikosdion commented 2 years ago

On Joomla 4, assuming that you are using SocialLogin 4, the intended redirection is divined from the call stack https://github.com/akeeba/sociallogin/blob/f3846c412ecab10659bc85f70b0d3ffd6629ae95/plugins/system/sociallogin/src/Features/ButtonInjection.php#L102

Currently, this only works for Joomla's mod_login. It does not work for com_users. If you find a good way to do this for com_users feel free to make a PR :)

sakiss commented 2 years ago

Thanks for getting back.

As far as i can see it reads the redirect url from the session. https://github.com/akeeba/sociallogin/blob/5eb5d81b53ec48a851719917dfe2d2a5fade7388/plugins/system/sociallogin/src/Library/Plugin/AbstractPlugin.php#L463

I suppose that it can solved by just storing those vars in the session in a prior stage. Not tested but this seems to be the case. If it cannot read the url from the com_user login menu item param, possibly can be added as a param in the plugins themselves. Better than nothing.

nikosdion commented 2 years ago

I told where the value ultimately stored in the session comes from and what's missing to make it complete for com_users.

No, setting the redirection in the plugin is architecturally WRONG. I am not doing that. That's a hard line.