[AC-2824] Refactor CLI auth-requests deny command to validate requests and improve exception handling (#9975)
This commit is contained in:
parent
36030c3763
commit
5b49412483
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue