From c6df7f956d97f396cd5d32a560feeb4ddb2d6e99 Mon Sep 17 00:00:00 2001 From: din9xtr Date: Sun, 18 Jan 2026 22:27:27 +0700 Subject: [PATCH] fix 2fa --- src/Controllers/ICloudAuthController.php | 6 ++++-- src/Rclone/RcloneICloudConfigurator.php | 26 +++++++++--------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Controllers/ICloudAuthController.php b/src/Controllers/ICloudAuthController.php index bf06a36..fd6f060 100644 --- a/src/Controllers/ICloudAuthController.php +++ b/src/Controllers/ICloudAuthController.php @@ -108,13 +108,15 @@ final readonly class ICloudAuthController $remote = 'icloud_' . $user->id; try { - $this->configurator->submit2fa($remote, $code); + $res = $this->configurator->submit2fa($remote, $code); $account = $this->repository->findByUserId($user->id); if ($account) { $this->repository->update($account, [ 'status' => 'connected', - 'connected_at' => time() + 'connected_at' => time(), + 'trust_token' => $res['trust_token'], + 'cookies' => $res['cookies'], ]); } diff --git a/src/Rclone/RcloneICloudConfigurator.php b/src/Rclone/RcloneICloudConfigurator.php index 11341b0..7566fa6 100644 --- a/src/Rclone/RcloneICloudConfigurator.php +++ b/src/Rclone/RcloneICloudConfigurator.php @@ -18,10 +18,7 @@ final readonly class RcloneICloudConfigurator * @throws ClientExceptionInterface * @throws JsonException */ - public function createRemote( - string $remote, - string $appleId - ): void + public function createRemote(string $remote, string $appleId): void { $this->rclone->call('config/create', [ 'name' => $remote, @@ -29,20 +26,15 @@ final readonly class RcloneICloudConfigurator 'parameters' => [ 'apple_id' => $appleId, ], - 'opt' => [ - 'nonInteractive' => true, - ], ]); + } /** * @throws ClientExceptionInterface * @throws JsonException */ - public function setPassword( - string $remote, - string $password - ): void + public function setPassword(string $remote, string $password): void { $this->rclone->call('config/password', [ 'name' => $remote, @@ -56,10 +48,7 @@ final readonly class RcloneICloudConfigurator * @throws ClientExceptionInterface * @throws JsonException */ - public function submit2fa( - string $remote, - string $code - ): void + public function submit2fa(string $remote, string $code): array { $this->rclone->call('config/update', [ 'name' => $remote, @@ -67,6 +56,12 @@ final readonly class RcloneICloudConfigurator 'config_2fa' => $code, ], ]); + + $config = $this->getConfig($remote); + return [ + 'trust_token' => $config['trust_token'] ?? null, + 'cookies' => $config['cookies'] ?? null, + ]; } /** @@ -79,5 +74,4 @@ final readonly class RcloneICloudConfigurator 'name' => $remote ]); } - }