0

我做了以下自定义防护:

<?php
namespace App\Auth;

use Illuminate\Http\Request;
use Illuminate\Auth\GuardHelpers;
use Illuminate\Contracts\Auth\Guard;

class LicenseGuard implements Guard
{
    use GuardHelpers;

    protected $request;

    public function __construct(LicenseUserProvider $provider, Request $request)
    {
        $this->provider = $provider;
        $this->request  = $request;
    }

    public function user ()
    {
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (!is_null($this->user))
            return $this->user;

        $user       = null;
        $licenseKey = $this->request->json('license_key');

        if (!empty($licenseKey)) {
            $user = $this->provider->retrieveByLicense($licenseKey);
        }

        return $this->user = $user;
    }

    public function validate (Array $credentials = [])
    {
       /* Validate code */
    }
}
?>

在我的中间件中,我定义了以下内容:

<?php
if($this->auth->guard($guard)->quest())
    return response('You have entered an unknown license key', 401);

我得到的错误是:
致命错误:调用未定义的方法 App\Auth\LicenseGuard::quest()

我正在使用具有“quest”方法的默认 GuardHelper 特征,我只是不知道为什么会发生这种情况。

我正在使用 PHP7 和 Lumen 5.2

4

1 回答 1

1

不知道你在做什么,我的朋友,但我认为quest“不是你要找的机器人”。

于 2016-02-25T20:52:16.467 回答