mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
refactor(core): Encapsulate logic to create new credential into its own method (#12361)
This commit is contained in:
@@ -147,32 +147,22 @@ export class CredentialsController {
|
||||
|
||||
@Post('/')
|
||||
async createCredentials(req: CredentialRequest.Create) {
|
||||
const newCredential = await this.credentialsService.prepareCreateData(req.body);
|
||||
|
||||
const encryptedData = this.credentialsService.createEncryptedData(null, newCredential);
|
||||
const { shared, ...credential } = await this.credentialsService.save(
|
||||
newCredential,
|
||||
encryptedData,
|
||||
req.user,
|
||||
req.body.projectId,
|
||||
);
|
||||
const newCredential = await this.credentialsService.createCredential(req.body, req.user);
|
||||
|
||||
const project = await this.sharedCredentialsRepository.findCredentialOwningProject(
|
||||
credential.id,
|
||||
newCredential.id,
|
||||
);
|
||||
|
||||
this.eventService.emit('credentials-created', {
|
||||
user: req.user,
|
||||
credentialType: credential.type,
|
||||
credentialId: credential.id,
|
||||
credentialType: newCredential.type,
|
||||
credentialId: newCredential.id,
|
||||
publicApi: false,
|
||||
projectId: project?.id,
|
||||
projectType: project?.type,
|
||||
});
|
||||
|
||||
const scopes = await this.credentialsService.getCredentialScopes(req.user, credential.id);
|
||||
|
||||
return { ...credential, scopes };
|
||||
return newCredential;
|
||||
}
|
||||
|
||||
@Patch('/:credentialId')
|
||||
|
||||
Reference in New Issue
Block a user