Last active
February 7, 2023 16:14
-
-
Save mikehins/4dcf7be3de0c16f6655fa281fa8ac7e1 to your computer and use it in GitHub Desktop.
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
Route::post('/token', function () { | |
if (app()->environment() !== 'local') { | |
return ['error' => 'Not authorized']; | |
} | |
$sanctum = new Sanctum::$personalAccessTokenModel; | |
$user = $sanctum->where('token', request()->token)->firstOrFail(); | |
$token = User::findOrFail($user->id)->createToken(request()->token); | |
return ['token' => $token->plainTextToken]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment