簡體   English   中英

Symfony\\Component\\Debug\\Exception\\FatalThrowableError:參數 1 傳遞給 Tymon\\JWTAuth\\JWTGuard::login()

[英]Symfony\Component\Debug\Exception\FatalThrowableError: Argument 1 passed to Tymon\JWTAuth\JWTGuard::login()

嘗試登錄 API 時出現此錯誤

Symfony\\Component\\Debug\\Exception\\FatalThrowableError:傳遞給 Tymon\\JWTAuth\\JWTGuard::login() 的參數 1 必須是 Tymon\\JWTAuth\\Contracts\\JWTSubject 的實例,給定的 App\\User 實例,在 /home/scrixmll 中調用/apiadmin.silexsecure.com/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php 文件 /home/scrixmll/apiadmin.silexsecure.com/vendor/tymon/jwt-auth/src/JWTGuard 中的第 307 行。第 140 行的 php

你需要在你的用戶模型中實現Tymon\\JWTAuth\\Contracts\\JWTSubject

use Illuminate\Foundation\Auth\User as Authenticatable;
use Tymon\JWTAuth\Contracts\JWTSubject;

class User extends Authenticatable implements JWTSubject
{
....

並聲明所需的方法

    /**
     * Get the identifier that will be stored in the subject claim of the JWT.
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM