Skip to content

Commit

Permalink
Update: change & configured required and necessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph.Hitachi authored and Ph.Hitachi committed Aug 12, 2023
1 parent 529f43e commit e6bd31d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
27 changes: 24 additions & 3 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Laravel\Sanctum\HasApiTokens;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
class User extends Authenticatable implements JWTSubject
{
use HasApiTokens, HasFactory, Notifiable;

Expand Down Expand Up @@ -42,4 +43,24 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
'password' => 'hashed',
];

/**
* 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 [];
}
}
7 changes: 6 additions & 1 deletion config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

'defaults' => [
'guard' => 'web',
'guard' => 'api',
'passwords' => 'users',
],

Expand All @@ -40,6 +40,11 @@
'driver' => 'session',
'provider' => 'users',
],
//add new guards for jwt
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
],

/*
Expand Down

0 comments on commit e6bd31d

Please sign in to comment.