sanctum auth check?
auth('sanctum')->check();
sanctum auth check?
auth('sanctum')->check();
laravel sanctum
Broadcast::routes(['middleware' => ['auth:sanctum']]);
laravel sanctum
composer create-project --prefer-dist laravel/laravel appname
composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
composer require laravel/jetstream
php artisan jetstream:install inertia
php artisan migrate
npm install
php artisan vendor:publish --tag=jetstream-views
php artisan serve
npm run hot
laravel sanctum
return $user->createToken('token-name', ['server:update'])->plainTextToken;
sanctum laravel
composer require laravel/sanctum
laravel sanctum
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\ValidationException;
Route::post('/sanctum/token', function (Request $request) {
$request->validate([
'email' => 'required|email',
'password' => 'required',
'device_name' => 'required',
]);
$user = User::where('email', $request->email)->first();
if (! $user || ! Hash::check($request->password, $user->password)) {
throw ValidationException::withMessages([
'email' => ['The provided credentials are incorrect.'],
]);
}
return $user->createToken($request->device_name)->plainTextToken;
});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us