This commit is contained in:
2026-01-18 22:27:27 +07:00
parent a43d38d87f
commit c6df7f956d
2 changed files with 14 additions and 18 deletions

View File

@@ -108,13 +108,15 @@ final readonly class ICloudAuthController
$remote = 'icloud_' . $user->id; $remote = 'icloud_' . $user->id;
try { try {
$this->configurator->submit2fa($remote, $code); $res = $this->configurator->submit2fa($remote, $code);
$account = $this->repository->findByUserId($user->id); $account = $this->repository->findByUserId($user->id);
if ($account) { if ($account) {
$this->repository->update($account, [ $this->repository->update($account, [
'status' => 'connected', 'status' => 'connected',
'connected_at' => time() 'connected_at' => time(),
'trust_token' => $res['trust_token'],
'cookies' => $res['cookies'],
]); ]);
} }

View File

@@ -18,10 +18,7 @@ final readonly class RcloneICloudConfigurator
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
* @throws JsonException * @throws JsonException
*/ */
public function createRemote( public function createRemote(string $remote, string $appleId): void
string $remote,
string $appleId
): void
{ {
$this->rclone->call('config/create', [ $this->rclone->call('config/create', [
'name' => $remote, 'name' => $remote,
@@ -29,20 +26,15 @@ final readonly class RcloneICloudConfigurator
'parameters' => [ 'parameters' => [
'apple_id' => $appleId, 'apple_id' => $appleId,
], ],
'opt' => [
'nonInteractive' => true,
],
]); ]);
} }
/** /**
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
* @throws JsonException * @throws JsonException
*/ */
public function setPassword( public function setPassword(string $remote, string $password): void
string $remote,
string $password
): void
{ {
$this->rclone->call('config/password', [ $this->rclone->call('config/password', [
'name' => $remote, 'name' => $remote,
@@ -56,10 +48,7 @@ final readonly class RcloneICloudConfigurator
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
* @throws JsonException * @throws JsonException
*/ */
public function submit2fa( public function submit2fa(string $remote, string $code): array
string $remote,
string $code
): void
{ {
$this->rclone->call('config/update', [ $this->rclone->call('config/update', [
'name' => $remote, 'name' => $remote,
@@ -67,6 +56,12 @@ final readonly class RcloneICloudConfigurator
'config_2fa' => $code, '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 'name' => $remote
]); ]);
} }
} }