0
votes

I have a website, which has a form. Within the form, I have a button linked to socialite where a user can click on it and it will retrieve the name and email from Facebook. Then, I redirect the user back to the form to either fill in the remaining information or submit the form.

However, all of the other information is lost upon return to the page.

I have tried to pass a 'Request $request' within the function. However, it never actually gets the information as the button isn't exactly submitting the form.

Is there any way of ensuring that the previous information is pushed through to the Route and that this information is then pushed back to the redirect?

Here is my code so far:

web.php

Route::get('login/{service}', 'Auth\LoginController@redirectToProvider')->name('social');
Route::get('login/{service}/callback', 'Auth\LoginController@handleProviderCallback');

LoginController.php

public function handleProviderCallback(Request $request, $service)
{
    $user = Socialite::driver($service)->stateless()->user();
    return redirect()->back()
        ->with(['social' => 'social', 'name' => $user->name, 'email' => $user->email])
        ->withInput($request->all);
}

(Note: within the view, I am, of course, using {{ old('input_name') }} to get the inputs whenever the form fails after submission.)

Is there any way to get the information from Socialite and return back to the form without losing the previous information?

All suggestions, help, and comments are highly appreciated :)

Thanks!!

1
Does the user need to be logged in to submit the form, or is the option just there to save them having to fill out some of their data?Rwd
Great question @RossWilson. No, the user does not need to be logged in to submit the form. In fact, this is just an option. So, you can fill in the form without doing this.Brad Ahrens

1 Answers

0
votes

The problem is when the user is redirected to social provider, say facebook, the form data will not in that request, so when facebook redirects to the callback you will not find the form data there! ( facebook will not carry it for you )

You likely need to use some javascript here. look at hellojs