Add session management
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { generateId } from "../utils/id";
|
||||
import { CreateUserInput, userModel } from "./user.schema";
|
||||
import { CreateUserInput, UpdateUserInput, userModel } from "./user.schema";
|
||||
|
||||
export async function createUser(input: CreateUserInput, tenantId: string) {
|
||||
const user = await userModel.create({
|
||||
@@ -13,9 +13,17 @@ export async function createUser(input: CreateUserInput, tenantId: string) {
|
||||
return user;
|
||||
}
|
||||
|
||||
export async function getUser(userId: string, tenantId: string) {
|
||||
export async function getUser(userId: string) {
|
||||
const user = await userModel.findOne({
|
||||
$and: [{ tenantId: tenantId }, { pid: userId }],
|
||||
$and: [{ pid: userId }],
|
||||
});
|
||||
return user;
|
||||
}
|
||||
|
||||
export async function getUserByEmail(email: string) {
|
||||
return await userModel.findOne({ email: email });
|
||||
}
|
||||
|
||||
export async function updateUser(userId: string, input: UpdateUserInput) {
|
||||
return await userModel.findOneAndUpdate({ pid: userId }, input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user