Add authorization
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user