Files
calendar/packages/lib/server/getUsersCredentials.ts
T
MorganandGitHub 7a9ddf2194 chore: rename DWD to DelegationCredential (#19703)
* chore: rename DWD to DelegationCredential

* fixup! chore: rename DWD to DelegationCredential

* fixup! fixup! chore: rename DWD to DelegationCredential

* fixup! Merge branch 'main' into rename-domain-wide-delegation

* fixup! fixup! Merge branch 'main' into rename-domain-wide-delegation

* fixup! fixup! fixup! Merge branch 'main' into rename-domain-wide-delegation
2025-03-04 09:45:39 -03:00

34 lines
951 B
TypeScript

import { prisma } from "@calcom/prisma";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
import { enrichUserWithDelegationCredentialsWithoutOrgId } from "../delegationCredential/server";
type SessionUser = NonNullable<TrpcSessionUser>;
type User = { id: SessionUser["id"]; email: SessionUser["email"] };
/**
* It includes in-memory DelegationCredential credentials as well.
*/
export async function getUsersCredentials(user: User) {
const credentials = await prisma.credential.findMany({
where: {
userId: user.id,
},
select: credentialForCalendarServiceSelect,
orderBy: {
id: "asc",
},
});
const { credentials: allCredentials } = await enrichUserWithDelegationCredentialsWithoutOrgId({
user: {
email: user.email,
id: user.id,
credentials,
},
});
return allCredentials;
}