mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 04:47:29 -08:00
464b565283
## Summary We accidentally made some functions `async` in https://github.com/n8n-io/n8n/pull/7846 This PR reverts that change. ## Review / Merge checklist - [x] PR title and summary are descriptive.
25 lines
787 B
TypeScript
25 lines
787 B
TypeScript
import { Service } from 'typedi';
|
|
import { DataSource, Repository } from 'typeorm';
|
|
import { SharedCredentials } from '../entities/SharedCredentials';
|
|
import type { User } from '../entities/User';
|
|
|
|
@Service()
|
|
export class SharedCredentialsRepository extends Repository<SharedCredentials> {
|
|
constructor(dataSource: DataSource) {
|
|
super(SharedCredentials, dataSource.manager);
|
|
}
|
|
|
|
/** Get a credential if it has been shared with a user */
|
|
async findCredentialForUser(credentialsId: string, user: User) {
|
|
const sharedCredential = await this.findOne({
|
|
relations: ['credentials'],
|
|
where: {
|
|
credentialsId,
|
|
...(!user.hasGlobalScope('credential:read') ? { userId: user.id } : {}),
|
|
},
|
|
});
|
|
if (!sharedCredential) return null;
|
|
return sharedCredential.credentials;
|
|
}
|
|
}
|