← Back to Social Login Support
The s?= and f?= redirect query string variables don't seem to trigger for google. Facebook redirects just fine (although it adds some weird #= to the end of the url). Haven't tried twitter.
Otherwise this plugin is rock solid! Thanks
I haven't figured out a good way to remove that stupid # bit from the Facebook redirect. It just seems to add it. Will look into Google redirects when I get time but the plugin is open source and PRs would be greatly appreciated.
Thanks Flyn, I'll certainly dig deeper when I have some free time as well and will open a PR if I get to the bottom of it. Thanks again for sharing!
Not entirely sure how to fix this, but I've identified where the problem arises.
In routes.php, on line 19:
$provider_response = $provider->login($provider_name, $action);
Before that line, the $success_redirect holds the variable just fine. After that line, it switches to the default ("/").
Going further, that line is calling the login() function on line 96 of socialloginproviders/Google.php.
Within that login() function, on line 118, the header() function is what's breaking the variable.
header("Location: $authUrl");
This is where I'm lost. That header() function is redirecting the route (I think), and thus losing the variable. I'm not sure how to retain it through that redirect.
Any help?
Last updated
I was able to get the redirects working by making use of the Google API's setState() method.
Basically it works like this: You can pass through a "state" with the Auth URL that doesn't do anything except carry information through the auth url so that you can retrieve it after the auth process has occurred.
So that "state" an be something as benign as "1" to something as complex as a base64 encoded parameter string. Then after the auth has occured, you grab that state again and use it to make your redirect path.
In terms of making it work for this plugin, you do something like following (I didn't make a pull request because I haven't tested my current mods on the other social logins since I'm only using Google -- and what I currently have will absolutely break the others):
Pass a $state variable from the route (in sociallogin > routes.php) into the provider->login() method (you have to mod the socialloginprovider abstract login to accept your new variable in addition to modding the Google, Facebook, and Twitter login() methods to accept those providers too.
Then in Google.php's getClient(), you add the state with: $client->setState($yourStateVariable);
Then back in the routes.php, towards the bottom before the"return Redirect::to($success_redirect)", you take that state and modify the $success_redirect.
For instance, imagine you want your login to redirect to the homepage or the account page, and those destinations vary on a state-by-state basis. You can set the state as either "1" or "2". When you retrieve the state at the end of the routes.php, you can set $success_redirect to either "/" or "/account" depending on whether a 1 or 2 was passed through.
Very convoluted explanation, but I hope that helps anybody looking for an answer right now.
Once/if I wind up incorporating twitter/facebook into our app, I'll clean it up and submit a formal PR that will bake this functionality into the plugin.
1-5 of 5