I am working on social login in Laravel. When passing parameter for identifying sign in and signup, it occurs error.
These are my router.
Route::get('/login/google', 'Auth\LoginController@google')->name('login.google'); //working well
Route::get('/login/google/{method}', 'Auth\LoginController@google')->name('login.google'); //not working
Route::get('/login/google/redirect', 'Auth\LoginController@googleRedirect');
This is my controller.
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Socialite;
class LoginController extends Controller
{
private $googleSign = '';
//public function google() //working well
public function google($method) //not working
{
$this->googleSign = $method;
return Socialite::driver('google')->redirect();
}
public function googleRedirect()
{
$user = Socialite::driver('google')->stateless()->user();
}
This is my view.
<a href="{{ route('login.google', 'signin') }}">
Sign in with Google
</a>
I just found a route issue.
Route::get('/login/google/{method}', 'Auth\LoginController@google')->name('login.google');
Route::get('/login/googleRedirect', 'Auth\LoginController@googleRedirect');