rts create bug fix

This commit is contained in:
2025-05-17 10:06:28 +05:30
parent 23c18c4875
commit 3fab49e3a8
2 changed files with 6 additions and 4 deletions

View File

@@ -8,9 +8,7 @@ import {
import { AuthenticatedUser } from "../auth";
import { generateId } from "../utils/id";
import { getFilterObject, getSortObject, PageQueryParams } from "../pagination";
import { getUser } from "../user/user.service";
import { orgModel } from "../organization/organization.schema";
import { userModel } from "../user/user.schema";
import { getUserWithoutPopulate } from "../user/user.service";
import mongoose from "mongoose";
export async function createRts(
@@ -18,7 +16,7 @@ export async function createRts(
user: AuthenticatedUser
) {
let defaultClient = input.client;
const userInDb = await getUser(user.userId);
const userInDb = await getUserWithoutPopulate(user.userId);
if (userInDb && userInDb.orgId) {
defaultClient = userInDb.orgId.toString();
}

View File

@@ -71,6 +71,10 @@ export async function getUser(userId: string) {
.populate({ path: "orgId", select: "_id pid name" });
}
export async function getUserWithoutPopulate(userId: string) {
return await userModel.findById(userId);
}
export async function getUserByToken(token: string) {
return await userModel.findOne({ "token.value": token });
}