gpt4 book ai didi

php - Laravel 5 身份验证器

转载 作者:行者123 更新时间:2023-12-03 18:58:22 25 4
gpt4 key购买 nike

我正在尝试实现社交名流,但出现与身份验证器类有关的错误。我的应用程序找不到它。

这是我的 Controller 中的代码

<?php namespace App;

use Illuminate\Contracts\Auth\Authenticator;
use App\Repositories\UserRepository as UserRepository;
use Laravel\Socialite\Contracts\Factory as Socialite;

class AuthenticateUser {

private $users;
private $socialite;
private $auth;
public function __construct(UserRepository $users, Socialite $socialite, Authenticator $auth)
{
$this->users = $users;
$this->socialite = $socialite;
$this->auth = $auth;
}
public function execute($hasCode)
{
if ( ! $hasCode ) return $this->getAuthorisationFirst();

$user = $this->socialite->drivers('google')->user();

dd($user);
}

private function getAuthorisationFirst()
{
return $this->socialite->driver('google')->redirect();
}

}

我收到的错误是

Container.php 第 833 行中的 ReflectionException:类 Illuminate\Contracts\Auth\Authenticator 不存在

最佳答案

似乎在 laravel 5 中,身份验证器现在称为 Guard

The Authenticator was renamed to Guard. In the AuthenticateUser.php file rename 'use Illuminate\Contracts\Auth\Authenticator;' to 'use Illuminate\Contracts\Auth\Guard;' and don't forget to also change it in constructor function too" –

关于php - Laravel 5 身份验证器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28435151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com