mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 20:29:08 +00:00
refactor(core): Encapsulate logic to create new credential into its own method (#12361)
This commit is contained in:
@@ -602,4 +602,25 @@ export class CredentialsService {
|
||||
mergedCredentials.data = decryptedData;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new credential in user's account and return it along the scopes
|
||||
* If a projectId is send, then it also binds the credential to that specific project
|
||||
*/
|
||||
async createCredential(credentialsData: CredentialRequest.CredentialProperties, user: User) {
|
||||
const newCredential = await this.prepareCreateData(credentialsData);
|
||||
|
||||
const encryptedData = this.createEncryptedData(null, newCredential);
|
||||
|
||||
const { shared, ...credential } = await this.save(
|
||||
newCredential,
|
||||
encryptedData,
|
||||
user,
|
||||
credentialsData.projectId,
|
||||
);
|
||||
|
||||
const scopes = await this.getCredentialScopes(user, credential.id);
|
||||
|
||||
return { ...credential, scopes };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user