Created
November 8, 2020 14:22
-
-
Save blogcacanid/7d00e8e9aa1df4dbd6befe4d3b69dd40 to your computer and use it in GitHub Desktop.
User.php Authentication JWT Lumen 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Auth\Authenticatable; | |
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; | |
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; | |
use Illuminate\Database\Eloquent\Model; | |
use Laravel\Lumen\Auth\Authorizable; | |
use Tymon\JWTAuth\Contracts\JWTSubject; | |
class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject | |
{ | |
use Authenticatable, Authorizable; | |
/** | |
* The attributes that are mass assignable. | |
* | |
* @var array | |
*/ | |
protected $fillable = [ | |
'username', 'email', 'password', | |
]; | |
/** | |
* The attributes excluded from the model's JSON form. | |
* | |
* @var array | |
*/ | |
protected $hidden = [ | |
'password', | |
]; | |
/** | |
* 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 []; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment