fix(lint): fix type errors

This commit is contained in:
lemmyMwaura
2024-08-07 22:59:50 +03:00
parent b0a5023723
commit 9061ec2dff
5 changed files with 22 additions and 20 deletions
+1
View File
@@ -21,6 +21,7 @@ export const SecretSharingSchema = z.object({
expiresAfterViews: z.number().nullable().optional(),
accessType: z.string().default("anyone"),
name: z.string().nullable().optional(),
password: z.string().nullable().optional(),
lastViewedAt: z.date().nullable().optional()
});
@@ -80,7 +80,6 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
orgId: req.permission?.orgId
});
// return undefined if it does not exist, has password set or has no more views allowed.
if (!sharedSecret || sharedSecret.password) return undefined;
return {
@@ -1,7 +1,7 @@
import bcrypt from "bcrypt";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
import { BadRequestError, ForbiddenRequestError, NotFoundError, UnauthorizedError } from "@app/lib/errors";
import { BadRequestError, ForbiddenRequestError, InternalServerError, NotFoundError, UnauthorizedError } from "@app/lib/errors";
import { SecretSharingAccessType } from "@app/lib/types";
import { TOrgDALFactory } from "../org/org-dal";
@@ -217,7 +217,12 @@ export const secretSharingServiceFactory = ({
if (accessType === SecretSharingAccessType.Organization && orgId !== sharedSecret.orgId)
throw new UnauthorizedError();
const isMatch = await bcrypt.compare(password, sharedSecret.password);
if (!sharedSecret.password)
throw new InternalServerError({
message: "Something went wrong"
});
const isMatch = await bcrypt.compare(password, sharedSecret.password as string);
if (!isMatch) return undefined
// we reduce the view count when we are sure the password matches.