diff --git a/bitwarden_license/bit-cli/src/admin-console/device-approval/deny.command.ts b/bitwarden_license/bit-cli/src/admin-console/device-approval/deny.command.ts index cf2356b195..58c1c57643 100644 --- a/bitwarden_license/bit-cli/src/admin-console/device-approval/deny.command.ts +++ b/bitwarden_license/bit-cli/src/admin-console/device-approval/deny.command.ts @@ -38,16 +38,18 @@ export class DenyCommand { } try { - await this.organizationAuthRequestService.denyPendingRequest(organizationId, id); - return Response.success(); - } catch (error) { - if (error?.statusCode === 404) { - return Response.error( - "The request id is invalid or you do not have permission to update it.", - ); + const pendingRequests = + await this.organizationAuthRequestService.listPendingRequests(organizationId); + + const request = pendingRequests.find((r) => r.id == id); + if (request == null) { + return Response.error("The request id is invalid."); } - return Response.error(error); + await this.organizationAuthRequestService.denyPendingRequest(organizationId, id); + return Response.success(); + } catch (e) { + return Response.error(e); } }