Skip to content

Commit 9629583

Browse files
Fixed user deletion with ajax cron jos
1 parent 2f92d2e commit 9629583

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/lib/Helper/User/DeleteUserDataHelper.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use OCA\Passwords\Db\EntityInterface;
1111
use OCA\Passwords\Helper\Settings\UserSettingsHelper;
1212
use OCA\Passwords\Services\ConfigurationService;
13+
use OCA\Passwords\Services\EnvironmentService;
1314
use OCA\Passwords\Services\Object\AbstractModelService;
1415
use OCA\Passwords\Services\Object\AbstractService;
1516
use OCA\Passwords\Services\Object\FolderService;
@@ -73,24 +74,24 @@ class DeleteUserDataHelper {
7374
/**
7475
* DeleteUserDataHelper constructor.
7576
*
76-
* @param null|string $userId
7777
* @param TagService $tagService
7878
* @param ShareService $shareService
7979
* @param UserSettingsHelper $settings
8080
* @param FolderService $folderService
8181
* @param ConfigurationService $config
82+
* @param EnvironmentService $environment
8283
* @param PasswordService $passwordService
8384
*/
8485
public function __construct(
85-
?string $userId,
8686
TagService $tagService,
8787
ShareService $shareService,
8888
UserSettingsHelper $settings,
8989
FolderService $folderService,
9090
ConfigurationService $config,
91+
EnvironmentService $environment,
9192
PasswordService $passwordService
9293
) {
93-
$this->userId = $userId;
94+
$this->userId = $environment->getUserId();
9495
$this->config = $config;
9596
$this->settings = $settings;
9697
$this->tagService = $tagService;
@@ -125,7 +126,9 @@ protected function deleteObjects(AbstractService $service, string $userId): void
125126
/** @var EntityInterface $objects */
126127
$objects = $service->findByUserId($userId);
127128

128-
foreach($objects as $tag) $service->delete($tag);
129+
foreach($objects as $tag) {
130+
$service->delete($tag);
131+
}
129132
}
130133

131134
/**
@@ -134,13 +137,17 @@ protected function deleteObjects(AbstractService $service, string $userId): void
134137
protected function deleteUserSettings(string $userId): void {
135138
$settings = array_keys($this->settings->list($userId));
136139

137-
foreach($settings as $setting) $this->settings->reset($setting, $userId);
140+
foreach($settings as $setting) {
141+
$this->settings->reset($setting, $userId);
142+
}
138143
}
139144

140145
/**
141146
* @param string $userId
142147
*/
143148
protected function deleteUserConfig(string $userId): void {
144-
foreach($this->userConfigKeys as $key) $this->config->deleteUserValue($key, $userId);
149+
foreach($this->userConfigKeys as $key) {
150+
$this->config->deleteUserValue($key, $userId);
151+
}
145152
}
146153
}

0 commit comments

Comments
 (0)