chore: refactor

This commit is contained in:
Ephraim Atta-Duncan
2025-04-30 23:48:48 +00:00
parent 30a4f2c7b4
commit 311adb4d1e
12 changed files with 35 additions and 39 deletions

View File

@ -5,6 +5,7 @@ import { prisma } from '@documenso/prisma';
import { AppError, AppErrorCode } from '../../errors/app-error';
import type { TDocumentAccessAuthTypes, TDocumentActionAuthTypes } from '../../types/document-auth';
import { DocumentAuth } from '../../types/document-auth';
import { createDocumentAuthOptions, extractDocumentAuthMethods } from '../../utils/document-auth';
export type UpdateTemplateOptions = {
@ -73,7 +74,11 @@ export const updateTemplate = async ({
data?.globalActionAuth === undefined ? documentGlobalActionAuth : data.globalActionAuth;
// Check if user has permission to set the global action auth.
if (newGlobalActionAuth) {
// Only ACCOUNT and PASSKEY require enterprise permissions
if (
newGlobalActionAuth &&
(newGlobalActionAuth === DocumentAuth.ACCOUNT || newGlobalActionAuth === DocumentAuth.PASSKEY)
) {
const isDocumentEnterprise = await isUserEnterprise({
userId,
teamId,
@ -81,7 +86,7 @@ export const updateTemplate = async ({
if (!isDocumentEnterprise) {
throw new AppError(AppErrorCode.UNAUTHORIZED, {
message: 'You do not have permission to set the action auth',
message: 'You do not have permission to set this action auth type',
});
}
}