From 76f1c43858b1afb66c0fe0115d01de1fc51611e5 Mon Sep 17 00:00:00 2001 From: Sergo Date: Sun, 13 Aug 2023 19:23:38 +0300 Subject: [PATCH] adj: prevent deleting non-managed addresses --- src/services/aliases/aliases.class.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/aliases/aliases.class.ts b/src/services/aliases/aliases.class.ts index ad6bf3f..9d5bbdc 100644 --- a/src/services/aliases/aliases.class.ts +++ b/src/services/aliases/aliases.class.ts @@ -125,9 +125,12 @@ export class AliasesService } sanitizeAliasResponse(alias: WildDuckAddress): AliasApiResponse { + // Prevent the user from deleting their main address or any address that does not end with the preferred domain + const isRemovable = !alias.main && alias.address.endsWith(config.get('wildDuck.domain')); + // Hide the id if the alias is not removable return { - id: alias.main ? null : alias.id, + id: isRemovable ? alias.id : null, address: alias.address, tags: alias.tags, created: alias.created,