1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01: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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
}
}