feat(core): Allow transferring credentials in Public API (#10259)

This commit is contained in:
Iván Ovejero
2024-08-02 12:02:38 +02:00
committed by GitHub
parent 489ce10063
commit 07d7b247f0
8 changed files with 127 additions and 5 deletions

View File

@@ -19,6 +19,8 @@ import {
toJsonSchema,
} from './credentials.service';
import { Container } from 'typedi';
import { z } from 'zod';
import { EnterpriseCredentialsService } from '@/credentials/credentials.service.ee';
export = {
createCredential: [
@@ -44,6 +46,20 @@ export = {
}
},
],
transferCredential: [
projectScope('credential:move', 'credential'),
async (req: CredentialRequest.Transfer, res: express.Response) => {
const body = z.object({ destinationProjectId: z.string() }).parse(req.body);
await Container.get(EnterpriseCredentialsService).transferOne(
req.user,
req.params.workflowId,
body.destinationProjectId,
);
res.status(204).send();
},
],
deleteCredential: [
projectScope('credential:delete', 'credential'),
async (