Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/user-service/src/users/users.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe("UsersController", () => {
});
});

it('should return "na" for userStatus if there is no many to many relationship', async () => {
it('should return "approved" for userStatus if user belongs to org without many-to-many relationship', async () => {
const user = await UserFactory.create();
const org = await OrganisationFactory.create();
await user.$set("organisation", org);
Expand All @@ -104,7 +104,7 @@ describe("UsersController", () => {
expect(relationship).toMatchObject({
type: "organisations",
id: org.uuid,
meta: { userStatus: "na" }
meta: { userStatus: "approved" }
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion apps/user-service/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export class UsersController {
const org = await user.primaryOrganisation();
if (org != null) {
const orgResource = document.addData(org.uuid, new OrganisationLightDto(org));
const userStatus = org.OrganisationUser?.status ?? "na";
const isOwner = user.organisationId === org.id;
const userStatus = isOwner ? "approved" : org.OrganisationUser?.status ?? "na";
userResource.relateTo("org", orgResource, { meta: { userStatus } });
}

Expand Down
Loading