feat: add organisations (#1820)

This commit is contained in:
David Nguyen
2025-06-10 11:49:52 +10:00
committed by GitHub
parent 0b37f19641
commit e6dc237ad2
631 changed files with 37616 additions and 25695 deletions

View File

@ -10,8 +10,30 @@ export const getApiTokenByToken = async ({ token }: { token: string }) => {
token: hashedToken,
},
include: {
team: true,
user: true,
team: {
include: {
organisation: {
include: {
owner: {
select: {
id: true,
name: true,
email: true,
disabled: true,
},
},
},
},
},
},
user: {
select: {
id: true,
name: true,
email: true,
disabled: true,
},
},
},
});
@ -25,11 +47,7 @@ export const getApiTokenByToken = async ({ token }: { token: string }) => {
// Handle a silly choice from many moons ago
if (apiToken.team && !apiToken.user) {
apiToken.user = await prisma.user.findFirst({
where: {
id: apiToken.team.ownerUserId,
},
});
apiToken.user = apiToken.team.organisation.owner;
}
const { user } = apiToken;