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 { CreateOrgInput, orgModel } from "./organization.schema";
export async function createOrg(input: CreateOrgInput) {
export async function createOrg(input: CreateOrgInput, tenantId: string) {
const org = await orgModel.create({
tenantId: "abc",
tenantId: tenantId,
pid: generateId(),
createdAt: new Date(),
...input,
@@ -12,6 +12,8 @@ export async function createOrg(input: CreateOrgInput) {
return org;
}
export async function getOrg(orgId: string) {
return await orgModel.findOne({ pid: orgId });
export async function getOrg(orgId: string, tenantId: string) {
return await orgModel.findOne({
$and: [{ tenantId: tenantId }, { pid: orgId }],
});
}