rts create bug fix
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user