Reputation: 105
I made the auth with socialite/facebook.
My code --
config/services.php:
'facebook' => [
'client_id' => 'client_id',
'client_secret' => 'client_secret',
'redirect' => 'http://www.example.com/facebook/callback',
],
routes.php:
Route::get('facebook', 'FacebookController@redirectToProvider');
Route::get('facebook/callback', 'FacebookController@handleProviderCallback');
FacebookController.php:
public function redirectToProvider()
{
return Socialite::with('facebook')->redirect();
}
public function handleProviderCallback(Request $request, User $user)
{
$users = Socialite::with('facebook')->user();
// user registration and login
// if the user is in the database, just login
return redirect()->back();
}
Everything works fine, the registration, the login and the redirect until one point.
If the app is already allowed, it redirects back normally. If you first authenticate with Facebook and allow the app, it does not redirect.
However, if the redirect is the homepage:
return redirect('/');
then it works too.
Upvotes: 1
Views: 543
Reputation: 105
So i found the solution here: http://laravel.io/forum/08-03-2014-redirect-to-the-second-last-page
My solved code:
public function redirectToProvider()
{
// added this
Session::flash('url',$_SERVER['HTTP_REFERER']);
return Socialite::with('facebook')->redirect();
}
public function handleProviderCallback(Request $request, User $user)
{
$users = Socialite::with('facebook')->user();
// user registration and login
// if the user is in the database, just login
// redirect changed from redirect()->back(); to this
return Redirect::to(Session::get('url'));
}
Upvotes: 2
Reputation: 759
Choose Your App in https://developers.facebook.com
and go through the App Review
option available in the dashboard and make your app public and full fill the Approval criteria
My main point is that you have everything ok in your side just make some small changes on developer dashboard in the facebook app.
Upvotes: 0