From 04d45c0a69e2cf2dc8231ea238a20169ef9c455c Mon Sep 17 00:00:00 2001 From: Sergo Date: Sun, 30 Jul 2023 11:01:06 +0300 Subject: [PATCH 1/3] fix delete btn --- public/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/public/index.js b/public/index.js index 7e6c207..86770f0 100644 --- a/public/index.js +++ b/public/index.js @@ -45,10 +45,8 @@ function renderAliases(aliases) { } }) - aDelete.classList.add('btn') - aDelete.classList.add('btn-danger') + aDelete.classList.add('btn', 'btn-danger') aDelete.innerText = 'Delete' - aDelete.setAttribute('href', `/aliases/${alias.id}`) tdActions.appendChild(aDelete) tr.appendChild(tdAddress) From 11107c04ed90bbb156cf25d461ae84b635991bb0 Mon Sep 17 00:00:00 2001 From: Sergo Date: Sun, 30 Jul 2023 11:15:41 +0300 Subject: [PATCH 2/3] allow the remove method --- src/services/aliases/aliases.class.ts | 7 +++++-- src/services/aliases/aliases.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/services/aliases/aliases.class.ts b/src/services/aliases/aliases.class.ts index e64ab35..af938e3 100644 --- a/src/services/aliases/aliases.class.ts +++ b/src/services/aliases/aliases.class.ts @@ -47,7 +47,7 @@ export interface AliasesParams extends Params { export class AliasesService implements ServiceInterface { - constructor(public options: AliasesServiceOptions) { } + constructor(public options: AliasesServiceOptions) {} async find(params: ServiceParams): Promise { const userId = await this.getUserIdByEmailAddress(params); @@ -117,7 +117,10 @@ export class AliasesService const allowedDomain: string = config.get("wildDuck.domain"); // If address does not match the allowed domain, throw an error - if (!allowedDomain || !addressInfoResponse.address.endsWith(allowedDomain)) { + if ( + !allowedDomain || + !addressInfoResponse.address.endsWith(allowedDomain) + ) { throw new BadRequest("Unable to delete address"); } diff --git a/src/services/aliases/aliases.ts b/src/services/aliases/aliases.ts index 0a6ed37..97ba226 100644 --- a/src/services/aliases/aliases.ts +++ b/src/services/aliases/aliases.ts @@ -3,7 +3,7 @@ import { validateAuth } from "../../hooks/validate-auth"; import { AliasesService, getOptions } from "./aliases.class"; export const aliasesPath = "aliases"; -export const aliasesMethods = ["find", "create"] as const; +export const aliasesMethods = ["find", "create", "remove"] as const; export * from "./aliases.class"; From bd7583cc2001dfbb43bed20e095cd4a62610b8f4 Mon Sep 17 00:00:00 2001 From: Sergo Date: Sun, 30 Jul 2023 11:27:10 +0300 Subject: [PATCH 3/3] fix deleting --- src/services/aliases/aliases.class.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/services/aliases/aliases.class.ts b/src/services/aliases/aliases.class.ts index af938e3..0f91d6c 100644 --- a/src/services/aliases/aliases.class.ts +++ b/src/services/aliases/aliases.class.ts @@ -47,7 +47,7 @@ export interface AliasesParams extends Params { export class AliasesService implements ServiceInterface { - constructor(public options: AliasesServiceOptions) {} + constructor(public options: AliasesServiceOptions) { } async find(params: ServiceParams): Promise { const userId = await this.getUserIdByEmailAddress(params); @@ -123,11 +123,10 @@ export class AliasesService ) { throw new BadRequest("Unable to delete address"); } - - await wildDuckClient.delete(`/addresses/${id}`); - const userId = await this.getUserIdByEmailAddress(params); + await wildDuckClient.delete(`users/${userId}/addresses/${id}`); + return this.getUserAddresses(userId); } }