Add authorization
This commit is contained in:
@@ -2,12 +2,13 @@ import bcrypt from "bcrypt";
|
||||
import { generateId, generateToken } from "../utils/id";
|
||||
import { CreateTokenInput, tokenModel } from "./token.schema";
|
||||
|
||||
export async function createToken(input: CreateTokenInput) {
|
||||
export async function createToken(input: CreateTokenInput, tenantId: string) {
|
||||
const tokenId = generateId();
|
||||
const newToken = await generateToken();
|
||||
const tokenHash = await bcrypt.hash(newToken, 10);
|
||||
|
||||
const tokenInDb = await tokenModel.create({
|
||||
tenantId: tenantId,
|
||||
pid: tokenId,
|
||||
hash: tokenHash,
|
||||
createdAt: new Date(),
|
||||
|
||||
Reference in New Issue
Block a user