blob: f44a2c70651b115f43a8fc1ba41de8e126de7822 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import { eq } from "drizzle-orm";
import { db } from "@karakeep/db";
import { users } from "@karakeep/db/schema";
import { AuthedContext } from "..";
export async function buildImpersonatingAuthedContext(
userId: string,
): Promise<AuthedContext> {
const user = await db.query.users.findFirst({
where: eq(users.id, userId),
});
if (!user) {
throw new Error("User not found");
}
return {
user: {
id: user.id,
name: user.name,
email: user.email,
role: user.role,
},
db,
req: {
ip: null,
},
};
}
|