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;
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'],
]);
}

View File

@@ -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
]);
}
}