MCPcopy
hub / github.com/Dokploy/dokploy / getUserByToken

Function getUserByToken

packages/server/src/services/admin.ts:67–97  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

65};
66
67export const getUserByToken = async (token: string) => {
68 const userResult = await db.query.invitation.findFirst({
69 where: eq(invitation.id, token),
70 columns: {
71 id: true,
72 email: true,
73 status: true,
74 expiresAt: true,
75 role: true,
76 inviterId: true,
77 },
78 });
79
80 if (!userResult) {
81 throw new TRPCError({
82 code: "NOT_FOUND",
83 message: "Invitation not found",
84 });
85 }
86
87 const userAlreadyExists = await db.query.user.findFirst({
88 where: eq(user.email, userResult?.email || ""),
89 });
90
91 const { expiresAt, ...rest } = userResult;
92 return {
93 ...rest,
94 isExpired: userResult.expiresAt < new Date(),
95 userAlreadyExists: !!userAlreadyExists,
96 };
97};
98
99export const removeUserById = async (userId: string) => {
100 await db

Callers 3

auth.tsFile · 0.90
getServerSidePropsFunction · 0.90
user.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected