summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/DeleteAccountService.ts
diff options
context:
space:
mode:
authorHazel K <acomputerdog@gmail.com>2024-10-07 10:02:49 -0400
committerHazel K <acomputerdog@gmail.com>2024-10-07 10:02:55 -0400
commita790fef2613015fac0bc4fb119abaa1f48de5841 (patch)
tree8245eedd5d243423de68c380be74a7cd3593c4b4 /packages/backend/src/core/DeleteAccountService.ts
parentmerge: Add controls to delete all files or sever all relations with a remote ... (diff)
downloadsharkey-a790fef2613015fac0bc4fb119abaa1f48de5841.tar.gz
sharkey-a790fef2613015fac0bc4fb119abaa1f48de5841.tar.bz2
sharkey-a790fef2613015fac0bc4fb119abaa1f48de5841.zip
prevent deletion or suspension of system accounts
Diffstat (limited to 'packages/backend/src/core/DeleteAccountService.ts')
-rw-r--r--packages/backend/src/core/DeleteAccountService.ts2
1 files changed, 2 insertions, 0 deletions
diff --git a/packages/backend/src/core/DeleteAccountService.ts b/packages/backend/src/core/DeleteAccountService.ts
index 7f1b8f3efb..8408e95863 100644
--- a/packages/backend/src/core/DeleteAccountService.ts
+++ b/packages/backend/src/core/DeleteAccountService.ts
@@ -13,6 +13,7 @@ import { GlobalEventService } from '@/core/GlobalEventService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
import { ModerationLogService } from '@/core/ModerationLogService.js';
+import { isSystemAccount } from '@/misc/is-system-account.js';
@Injectable()
export class DeleteAccountService {
@@ -38,6 +39,7 @@ export class DeleteAccountService {
}, moderator?: MiUser): Promise<void> {
const _user = await this.usersRepository.findOneByOrFail({ id: user.id });
if (_user.isRoot) throw new Error('cannot delete a root account');
+ if (isSystemAccount(_user)) throw new Error('cannot delete a system account');
if (moderator != null) {
this.moderationLogService.log(moderator, 'deleteAccount', {