Add authorization
This commit is contained in:
@@ -3,24 +3,22 @@ import { CreateTokenInput } from "./token.schema";
|
||||
import { createToken, getToken } from "./token.service";
|
||||
|
||||
export async function createTokenHandler(
|
||||
req: FastifyRequest<{ Body: CreateTokenInput }>,
|
||||
req: FastifyRequest,
|
||||
res: FastifyReply
|
||||
) {
|
||||
const input = req.body;
|
||||
const input = req.body as CreateTokenInput;
|
||||
|
||||
try {
|
||||
const result = await createToken(input);
|
||||
const authUser = req.user;
|
||||
const result = await createToken(input, authUser.tenantId);
|
||||
return res.code(201).send(result);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTokenHandler(
|
||||
req: FastifyRequest<{ Params: { tokenId: string } }>,
|
||||
res: FastifyReply
|
||||
) {
|
||||
const { tokenId } = req.params;
|
||||
export async function getTokenHandler(req: FastifyRequest, res: FastifyReply) {
|
||||
const { tokenId } = req.params as { tokenId: string };
|
||||
|
||||
try {
|
||||
const token = await getToken(tokenId);
|
||||
|
||||
Reference in New Issue
Block a user