Skip to content

Commit

Permalink
refactor(core): Convert OAuth1/OAuth2 routes to decorated controller …
Browse files Browse the repository at this point in the history
…classes (no-changelog) (#5973)
  • Loading branch information
netroy authored Nov 3, 2023
1 parent c6049a2 commit acec9ba
Show file tree
Hide file tree
Showing 17 changed files with 977 additions and 671 deletions.
46 changes: 1 addition & 45 deletions packages/cli/src/CredentialsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
import { NodeTypes } from '@/NodeTypes';
import { CredentialTypes } from '@/CredentialTypes';
import { CredentialsOverwrites } from '@/CredentialsOverwrites';
import { whereClause } from './UserManagement/UserManagementHelper';
import { RESPONSE_ERROR_MESSAGES } from './constants';
import { isObjectLiteral } from './utils';
import { Logger } from '@/Logger';
Expand Down Expand Up @@ -213,7 +212,7 @@ export class CredentialsHelper extends ICredentialsHelper {
/**
* Resolves the given value in case it is an expression
*/
resolveValue(
private resolveValue(
parameterValue: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys,
workflow: Workflow,
Expand Down Expand Up @@ -248,9 +247,6 @@ export class CredentialsHelper extends ICredentialsHelper {

/**
* Returns the credentials instance
*
* @param {INodeCredentialsDetails} nodeCredential id and name to return instance of
* @param {string} type Type of the credential to return instance of
*/
async getCredentials(
nodeCredential: INodeCredentialsDetails,
Expand Down Expand Up @@ -284,8 +280,6 @@ export class CredentialsHelper extends ICredentialsHelper {

/**
* Returns all the properties of the credentials with the given name
*
* @param {string} type The name of the type to return credentials off
*/
getCredentialsProperties(type: string): INodeProperties[] {
const credentialTypeData = this.credentialTypes.getByName(type);
Expand Down Expand Up @@ -327,10 +321,6 @@ export class CredentialsHelper extends ICredentialsHelper {

/**
* Returns the decrypted credential data with applied overwrites
*
* @param {INodeCredentialsDetails} nodeCredentials id and name to return instance of
* @param {string} type Type of the credentials to return data of
* @param {boolean} [raw] Return the data as supplied without defaults or overwrites
*/
async getDecrypted(
additionalData: IWorkflowExecuteAdditionalData,
Expand Down Expand Up @@ -443,10 +433,6 @@ export class CredentialsHelper extends ICredentialsHelper {

/**
* Updates credentials in the database
*
* @param {string} name Name of the credentials to set data of
* @param {string} type Type of the credentials to set data of
* @param {ICredentialDataDecryptedObject} data The data to set
*/
async updateCredentials(
nodeCredentials: INodeCredentialsDetails,
Expand Down Expand Up @@ -804,36 +790,6 @@ export class CredentialsHelper extends ICredentialsHelper {
}
}

/**
* Get a credential if it has been shared with a user.
*/
export async function getCredentialForUser(
credentialId: string,
user: User,
): Promise<ICredentialsDb | null> {
const sharedCredential = await Db.collections.SharedCredentials.findOne({
relations: ['credentials'],
where: whereClause({
user,
entityType: 'credentials',
entityId: credentialId,
}),
});

if (!sharedCredential) return null;

return sharedCredential.credentials as ICredentialsDb;
}

/**
* Get a credential without user check
*/
export async function getCredentialWithoutUser(
credentialId: string,
): Promise<ICredentialsDb | null> {
return Db.collections.Credentials.findOneBy({ id: credentialId });
}

export function createCredentialsFromCredentialsEntity(
credential: CredentialsEntity,
encrypt = false,
Expand Down
Loading

0 comments on commit acec9ba

Please sign in to comment.