0

my LoginController:

namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{


use AuthenticatesUsers;

/**
 * Where to redirect users after login.
 *
 * @var string
 */
protected $redirectTo = RouteServiceProvider::HOME;

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest')->except('logout');
}

public function redirectToProvider() 
{
    return  Socialite::driver('facebook')->redirect();
}

public function handleProviderCallBack()
{
    $user = Socialite::driver('facebook')->user();
}

}

my web.php:

Route::get('login/facebook', 'App/Http/Controllers/Auth/LoginController@redirectToProvider');
Route::get('login/facebook/callback', 
'App/Http/Controllers/Auth/LoginController@handleProviderCallBack');

And my editor looks me red line on Socialite and give me error undefined type' App\Http\Controllers\Auth\Socialite'.

also when i in browser url 'http://localhost/public/blog/login/facebook' it gives me 404 not found.

also i use in LoginController use Illuminate\Support\Facades\Auth; use Laravel\Socialite\Facades\Socialite; but it doesn't work

can anyone help me?

jarlh
  • 42,561
  • 8
  • 45
  • 63
Leo
  • 1
  • 4
  • The [documentation](https://laravel.com/docs/8.x/socialite) didn't help? It mentions `use Laravel\Socialite\Facades\Socialite;` which I don't see anywhere in your code – brombeer Aug 19 '21 at 12:16
  • i try it but it doesn't work – Leo Aug 19 '21 at 12:18
  • did you clear the route cache ? `php artisan route:cache` – Gert B. Aug 19 '21 at 12:19
  • it does not work – Leo Aug 19 '21 at 12:21
  • Does any of your other routes work? I see you have `/public/blog/` in your URL. That could be a problem – Gert B. Aug 19 '21 at 12:29
  • what url can i use to solve 404 not found – Leo Aug 19 '21 at 12:31
  • Your applications "public" folder should be the root folder of your domain. A easy solution would be using `php artisan serve` and using the generated link. – Gert B. Aug 19 '21 at 12:38
  • i found my website and it gives me error syntax error, unexpected identifier "Route", but i checked it and there isn't false in code – Leo Aug 19 '21 at 12:42
  • Unexpected identifier "Route" indicates your line above the line of the error is not closed properly. most of the time you are missing a `;`, If it says "Syntax error", there is a problem with your code, thats a fact. – Gert B. Aug 19 '21 at 12:44
  • now i have error Target class [App/Http/Controllers/Auth/LoginController] does not exist. – Leo Aug 19 '21 at 12:53
  • @Leo thats a whole other problem, look at the docs on Laravel routing, check if the class exists... You don't need the whole namespace there. – Gert B. Aug 19 '21 at 12:57
  • Dude, your [question](https://stackoverflow.com/questions/68849480/target-class-app-http-controllers-auth-logincontroller-does-not-exist) is duplicate. – Mahbod Ahmadi Aug 20 '21 at 19:50

0 Answers0