Add authorization

This commit is contained in:
2024-12-20 13:17:53 +05:30
parent 4b49c43a0c
commit a584fc91b5
16 changed files with 112 additions and 58 deletions

View File

@@ -1,9 +1,9 @@
import { generateId } from "../utils/id";
import { CreateUserInput, userModel } from "./user.schema";
export async function createUser(input: CreateUserInput) {
export async function createUser(input: CreateUserInput, tenantId: string) {
const user = await userModel.create({
tenantId: "abc",
tenantId: tenantId,
pid: generateId(),
createdAt: new Date(),
...input,
@@ -12,7 +12,9 @@ export async function createUser(input: CreateUserInput) {
return user;
}
export async function getUser(userId: string) {
const user = await userModel.findOne({ pid: userId });
export async function getUser(userId: string, tenantId: string) {
const user = await userModel.findOne({
$and: [{ tenantId: tenantId }, { pid: userId }],
});
return user;
}