-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d814dc3
commit a8c45cd
Showing
13 changed files
with
74 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Services\Auth; | ||
|
||
use Illuminate\Http\Request; | ||
use Laravel\Sanctum\Events\TokenAuthenticated; | ||
use Laravel\Sanctum\Guard as SanctumGuard; | ||
use Laravel\Sanctum\Sanctum; | ||
|
||
class ApiSanctumGuard extends SanctumGuard | ||
{ | ||
/** | ||
* Override to avoid: | ||
* - Checking 'web' guard first (or whatever other guards are in sanctum.php) | ||
* - Setting modified fields of PAT | ||
*/ | ||
public function __invoke(Request $request) | ||
{ | ||
if ($token = $this->getTokenFromRequest($request)) { | ||
$model = Sanctum::$personalAccessTokenModel; | ||
|
||
$accessToken = $model::findToken($token); | ||
|
||
if (! $this->isValidAccessToken($accessToken) || | ||
! $this->supportsTokens($accessToken->tokenable)) { | ||
return; | ||
} | ||
|
||
$tokenable = $accessToken->tokenable->withAccessToken( | ||
$accessToken | ||
); | ||
|
||
event(new TokenAuthenticated($accessToken)); | ||
|
||
return $tokenable; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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