adj: prevent deleting non-managed addresses
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Sergo 2023-08-13 19:23:38 +03:00
parent a2d344ceb4
commit 76f1c43858

View File

@ -125,9 +125,12 @@ export class AliasesService<ServiceParams extends AliasesParams = AliasesParams>
} }
sanitizeAliasResponse(alias: WildDuckAddress): AliasApiResponse { 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 // Hide the id if the alias is not removable
return { return {
id: alias.main ? null : alias.id, id: isRemovable ? alias.id : null,
address: alias.address, address: alias.address,
tags: alias.tags, tags: alias.tags,
created: alias.created, created: alias.created,