// зависимости
use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\RegisterRequest;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Laravel\Passport\Client;
use Illuminate\Support\Facades\Password;
use Illuminate\Auth\Events\PasswordReset;
public function login(LoginRequest $request)
{
$client = Client::query()->where('password_client', 1)->first();
$response = Http::asForm()->post( url('/').'/oauth/token', [
'grant_type' => 'password',
'client_id' => $client->id,
'client_secret' => $client->secret,
'username' => $request->email,
'password' => $request->password,
'scope' => '',
]);
return response()->json([
'success' => true,
'access_token' => $response['access_token'],
'expires_in' => $response['expires_in'],
'token_type' => $response['token_type'],
])->withCookie('refresh_token', $response['refresh_token'], 43200);
}