mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix: Add missing content type to controllers (no-changelog) (#4617)
* fix: add missing content type to controllers * refactor: use ResponseHelper instead of fixing content type * fix: remove res.send calls
This commit is contained in:
parent
b0bbcf6028
commit
b4cec38ee8
|
@ -134,18 +134,23 @@ EECredentialsController.post(
|
|||
* Grant or remove users' access to a credential.
|
||||
*/
|
||||
|
||||
EECredentialsController.put('/:credentialId/share', async (req: CredentialRequest.Share, res) => {
|
||||
EECredentialsController.put(
|
||||
'/:credentialId/share',
|
||||
ResponseHelper.send(async (req: CredentialRequest.Share) => {
|
||||
const { credentialId } = req.params;
|
||||
const { shareWithIds } = req.body;
|
||||
|
||||
if (!Array.isArray(shareWithIds) || !shareWithIds.every((userId) => typeof userId === 'string')) {
|
||||
return res.status(400).send('Bad Request');
|
||||
if (
|
||||
!Array.isArray(shareWithIds) ||
|
||||
!shareWithIds.every((userId) => typeof userId === 'string')
|
||||
) {
|
||||
throw new ResponseHelper.ResponseError('Bad request', undefined, 400);
|
||||
}
|
||||
|
||||
const { ownsCredential, credential } = await EECredentials.isOwned(req.user, credentialId);
|
||||
|
||||
if (!ownsCredential || !credential) {
|
||||
return res.status(403).send();
|
||||
throw new ResponseHelper.ResponseError('Forbidden', undefined, 403);
|
||||
}
|
||||
|
||||
let amountRemoved: number | null = null;
|
||||
|
@ -178,6 +183,5 @@ EECredentialsController.put('/:credentialId/share', async (req: CredentialReques
|
|||
user_ids_sharees_added: newShareeIds,
|
||||
sharees_removed: amountRemoved,
|
||||
});
|
||||
|
||||
return res.status(200).send();
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -37,18 +37,23 @@ EEWorkflowController.use((req, res, next) => {
|
|||
* Grant or remove users' access to a workflow.
|
||||
*/
|
||||
|
||||
EEWorkflowController.put('/:workflowId/share', async (req: WorkflowRequest.Share, res) => {
|
||||
EEWorkflowController.put(
|
||||
'/:workflowId/share',
|
||||
ResponseHelper.send(async (req: WorkflowRequest.Share) => {
|
||||
const { workflowId } = req.params;
|
||||
const { shareWithIds } = req.body;
|
||||
|
||||
if (!Array.isArray(shareWithIds) || !shareWithIds.every((userId) => typeof userId === 'string')) {
|
||||
return res.status(400).send('Bad Request');
|
||||
if (
|
||||
!Array.isArray(shareWithIds) ||
|
||||
!shareWithIds.every((userId) => typeof userId === 'string')
|
||||
) {
|
||||
throw new ResponseHelper.ResponseError('Bad request', undefined, 400);
|
||||
}
|
||||
|
||||
const { ownsWorkflow, workflow } = await EEWorkflows.isOwned(req.user, workflowId);
|
||||
|
||||
if (!ownsWorkflow || !workflow) {
|
||||
return res.status(403).send();
|
||||
throw new ResponseHelper.ResponseError('Forbidden', undefined, 403);
|
||||
}
|
||||
|
||||
let newShareeIds: string[] = [];
|
||||
|
@ -68,9 +73,8 @@ EEWorkflowController.put('/:workflowId/share', async (req: WorkflowRequest.Share
|
|||
await EEWorkflows.share(trx, workflow, newShareeIds);
|
||||
}
|
||||
});
|
||||
|
||||
return res.status(200).send();
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
EEWorkflowController.get(
|
||||
'/:id(\\d+)',
|
||||
|
|
Loading…
Reference in a new issue