1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 05:43:41 +00:00

[AC-2824] Refactor CLI auth-requests deny command to validate requests and improve exception handling (#9975)

This commit is contained in:
Rui Tomé
2024-07-11 14:46:15 +01:00
committed by GitHub
parent 36030c3763
commit 5b49412483

View File

@@ -38,16 +38,18 @@ export class DenyCommand {
} }
try { try {
await this.organizationAuthRequestService.denyPendingRequest(organizationId, id); const pendingRequests =
return Response.success(); await this.organizationAuthRequestService.listPendingRequests(organizationId);
} catch (error) {
if (error?.statusCode === 404) { const request = pendingRequests.find((r) => r.id == id);
return Response.error( if (request == null) {
"The request id is invalid or you do not have permission to update it.", 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);
} }
} }