update user schema, limit rts to client users

This commit is contained in:
2025-05-06 14:15:36 +05:30
parent c7e6b209e9
commit 16428cf895
4 changed files with 38 additions and 42 deletions

View File

@@ -54,12 +54,16 @@ export async function createUser(
export async function getUser(userId: string) {
if (mongoose.Types.ObjectId.isValid(userId)) {
return await userModel.findById(userId);
return await userModel
.findById(userId)
.populate({ path: "orgId", select: "_id pid name" });
}
return await userModel.findOne({
$and: [{ pid: userId }],
});
return await userModel
.findOne({
$and: [{ pid: userId }],
})
.populate({ path: "orgId", select: "_id pid name" });
}
export async function getUserByToken(token: string) {