Skip to content

Commit

Permalink
fix: getOrganisationsForUser function does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaumaus committed Dec 14, 2024
1 parent cfdaf51 commit 09afb8f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion backend/apps/cloud/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 2 additions & 21 deletions backend/apps/cloud/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/cloud/src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
])
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/cloud/src/user/user.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { OrganisationModule } from '../organisation/organisation.module'
forwardRef(() => AuthModule),
AppLoggerModule,
ProjectModule,
forwardRef(() => OrganisationModule),
OrganisationModule,
PayoutsModule,
HttpModule,
],
Expand Down
21 changes: 21 additions & 0 deletions backend/apps/cloud/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -109,6 +110,7 @@ export class UserService {
@InjectRepository(DeleteFeedback)
private readonly deleteFeedbackRepository: Repository<DeleteFeedback>,
private readonly payoutsService: PayoutsService,
private readonly organisationService: OrganisationService,
) {}

async create(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 09afb8f

Please sign in to comment.