Laravel 5 and Socialite - new redirection after login

Another new question is here, but hopefully someone can shed some light:

I am using Socialite with Laravel 5, and I want to be able to redirect the user to a page on the site after logging in. The problem is that using

return redirect('any-path-I-put-here');

just redirects back to "social-site / login? code = afkjadfkjdslkfjdlkfj ..." (where "social site" is any site that is used, for example, facebook, twitter, google, etc.)

So, it seems to me that the redirect () function in the Socialite / Contracts / Provider interface overrides any redirection that I try to do after the fact.

Just to clarify, my routes are configured correctly. I tried every version of the "redirect" that you can imagine ("to", "back", "designed", "Redirect :: etc."), And the method is called from my Auth Controller (although I tried it elsewhere as well).

The question is, how do I override this redirect () when I finished storing and registering the user using the socialite user? Any help is appreciated! Thank you in advance.

Code containing the specified call forwarding:

public function socialRedirect( $route, $status, $greeting, $user )
{

    $this->auth->login( $user, true );

    if( $status == 'new_user' ) {
        // This is a new member. Make sure they see the welcome modal on redirect
        \Session::flash( 'new_registration', true );

        return redirect()->to( $route );// This is just the most recent attempt. It originated with return redirect($route);, and has been attempted every other way you can imagine as well (as mentioned above). Hardcoding (i.e., 'home') returns the exact same result. The socialite redirect always overrides anything that is put here.
    }
    else {
        return redirect()->to( $route )->with( [ 'greeting' => $greeting ] );
    }
}

... SocialAuth, , 500 , , , , , .. , , Social Auth:

private function socialLogin( $socialUser, $goto, $provider, $status, $controller )
{
    if( is_null( $goto ) ) {
        $goto = 'backlot/' . $socialUser->profile->custom_url;
    }

    if( $status == 'new_user' ) {
        return $controller->socialRedirect($goto, $status, null, $socialUser);
    }
    else {
        // This is an existing member. Show them the welcome back status message.
        $message = 'You have successfully logged in with your ' .
            ucfirst( $provider ) . ' credentials.';

        $greeting =
            flash()->success( 'Welcome back, ' . $socialUser->username . '. ' . $message );

        return $controller->socialRedirect($goto, $status, $greeting, $socialUser);
    }
}
+5
3

, . Socialite :

config/services.php. :

 'facebook' => [
    'client_id' => 'your_fb_id',
    'client_secret' => 'your_fb_secret',
    'redirect' => '>ABSOLUTE< url to redirect after login', //like: 'http://stuff'
  ],

, ( ).

:

return \Socialize::with('facebook')->redirect();

$fb_user = \Socialize::with('facebook')->user();
// check if user exists, create it and whatnot
//dd($fb_user);
return redirect()->route('some.route');

.

+1

, , . , , , URL-.

Laravel. , , return redirect()->route('dashboard');. redirect() Redirect, .

, . . , .

( , ), (F5), , . , . , (, Laravel , ). . , .

, http header("Location /dashboard"); . , , ( URL-) DashboardController.

, , , .

+1

Socialite UserController . AuthenticatesSocialiteLogin:: loginSuccess() .

use Broco\SocialiteLogin\Auth\AuthenticatesSocialiteLogin;

class UserController extends BaseController
{
    use AuthenticatesSocialiteLogin;

    public function loginSuccess($user)
    {
        return redirect()->intended(url('/#login-success'));
    }

....
0

All Articles