Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: getOrganisationsForUser function does not exist

Blue Mouse09afb8f1e3ba
diff --git a/backend/apps/cloud/src/auth/auth.controller.ts b/backend/apps/cloud/src/auth/auth.controller.ts
index 1d9a191de..33b53ac79 100644
--- a/backend/apps/cloud/src/auth/auth.controller.ts
+++ b/backend/apps/cloud/src/auth/auth.controller.ts
@@ -168,7 +168,7 @@ export class AuthController {
} else {
const [sharedProjects, organisationMemberships] = await Promise.all([
this.authService.getSharedProjectsForUser(user.id),
- this.authService.getOrganisationsForUser(user.id),
+ this.userService.getOrganisationsForUser(user.id),
])
user.sharedProjects = sharedProjects
diff --git a/backend/apps/cloud/src/auth/auth.service.ts b/backend/apps/cloud/src/auth/auth.service.ts
index e74d85db9..c245a3d43 100644
--- a/backend/apps/cloud/src/auth/auth.service.ts
+++ b/backend/apps/cloud/src/auth/auth.service.ts
@@ -212,25 +212,6 @@ export class AuthService {
})
}
- async getOrganisationsForUser(userId: string) {
- return this.organisationService.findMemberships({
- where: {
- user: { id: userId },
- },
- relations: ['organisation'],
- select: {
- id: true,
- role: true,
- confirmed: true,
- created: true,
- organisation: {
- id: true,
- name: true,
- },
- },
- })
- }
-
private async comparePassword(
password: string,
hashedPassword: string,
@@ -519,7 +500,7 @@ export class AuthService {
} else {
const [sharedProjects, organisationMemberships] = await Promise.all([
this.getSharedProjectsForUser(user.id),
- this.getOrganisationsForUser(user.id),
+ this.userService.getOrganisationsForUser(user.id),
])
user.sharedProjects = sharedProjects
@@ -986,7 +967,7 @@ export class AuthService {
} else {
const [sharedProjects, organisationMemberships] = await Promise.all([
this.getSharedProjectsForUser(user.id),
- this.getOrganisationsForUser(user.id),
+ this.userService.getOrganisationsForUser(user.id),
])
user.sharedProjects = sharedProjects
diff --git a/backend/apps/cloud/src/user/user.controller.ts b/backend/apps/cloud/src/user/user.controller.ts
index d0c428825..136f43fe0 100644
--- a/backend/apps/cloud/src/user/user.controller.ts
+++ b/backend/apps/cloud/src/user/user.controller.ts
@@ -108,7 +108,7 @@ export class UserController {
const [sharedProjects, organisationMemberships, user, totalMonthlyEvents] =
await Promise.all([
this.authService.getSharedProjectsForUser(uid),
- this.authService.getOrganisationsForUser(uid),
+ this.userService.getOrganisationsForUser(uid),
this.userService.findOne({ where: { id: uid } }),
this.projectService.getRedisCount(uid),
])
diff --git a/backend/apps/cloud/src/user/user.module.ts b/backend/apps/cloud/src/user/user.module.ts
index a40972411..8e2d8463a 100644
--- a/backend/apps/cloud/src/user/user.module.ts
+++ b/backend/apps/cloud/src/user/user.module.ts
@@ -25,7 +25,7 @@ import { OrganisationModule } from '../organisation/organisation.module'
forwardRef(() => AuthModule),
AppLoggerModule,
ProjectModule,
- forwardRef(() => OrganisationModule),
+ OrganisationModule,
PayoutsModule,
HttpModule,
],
diff --git a/backend/apps/cloud/src/user/user.service.ts b/backend/apps/cloud/src/user/user.service.ts
index e310eea32..d13954763 100644
--- a/backend/apps/cloud/src/user/user.service.ts
+++ b/backend/apps/cloud/src/user/user.service.ts
@@ -40,6 +40,7 @@ import { UserGoogleDTO } from './dto/user-google.dto'
import { UserGithubDTO } from './dto/user-github.dto'
import { EMAIL_ACTION_ENCRYPTION_KEY } from '../common/constants'
import { ReportFrequency } from '../project/enums'
+import { OrganisationService } from '../organisation/organisation.service'
dayjs.extend(utc)
@@ -109,6 +110,7 @@ export class UserService {
@InjectRepository(DeleteFeedback)
private readonly deleteFeedbackRepository: Repository<DeleteFeedback>,
private readonly payoutsService: PayoutsService,
+ private readonly organisationService: OrganisationService,
) {}
async create(
@@ -296,6 +298,25 @@ export class UserService {
})
}
+ async getOrganisationsForUser(userId: string) {
+ return this.organisationService.findMemberships({
+ where: {
+ user: { id: userId },
+ },
+ relations: ['organisation'],
+ select: {
+ id: true,
+ role: true,
+ confirmed: true,
+ created: true,
+ organisation: {
+ id: true,
+ name: true,
+ },
+ },
+ })
+ }
+
async updateUserTelegramId(
userId: string,
telegramId: number | null,