1 回答
TA贡献1796条经验 获得超7个赞
我找到了问题的解决方案。这是我的错误,因为我的User.php模型中有拼写错误
变更前型号:
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
'verified', 'balance', 'isAdmin',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'verified',
];
/**
* getJWTCustomClaims
*
* @return mixed
*/
public function getJWTCustomClaims()
{
return [];
}
/**
* getJWTIdentifier
*
* @return array
*/
public function getJWTIdentifier()
{
return $this->key;
}
/**
* RelationShip between user, and user activation token
*
* @return void
*/
public function verifyToken()
{
return $this->hasOne(UserVerification::class);
}
}
变更后型号:
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
'verified', 'balance', 'isAdmin',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'verified',
];
/**
* getJWTCustomClaims
*
* @return mixed
*/
public function getJWTCustomClaims()
{
return [];
}
/**
* getJWTIdentifier
*
* @return array
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* RelationShip between user, and user activation token
*
* @return void
*/
public function verifyToken()
{
return $this->hasOne(UserVerification::class);
}
}
所以我将getJWTIdentifier()返回从更改$this->key为$this->getKey()
- 1 回答
- 0 关注
- 89 浏览
添加回答
举报