mirror of
https://github.com/documenso/documenso.git
synced 2026-08-16 03:21:55 +10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9142a3799a | ||
|
|
8a77747820 | ||
|
|
e7b66fe069 |
@@ -1,7 +1,6 @@
|
||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import {
|
||||
decryptEmailTransportConfig,
|
||||
EMAIL_TRANSPORT_SECRET_KEYS,
|
||||
encryptEmailTransportConfig,
|
||||
ZEmailTransportConfigSchema,
|
||||
} from '@documenso/lib/server-only/email/email-transport-config';
|
||||
@@ -30,16 +29,16 @@ export const updateEmailTransportRoute = adminProcedure
|
||||
const existingConfig = decryptEmailTransportConfig(existing.config);
|
||||
|
||||
// Start from the incoming config; backfill empty secret fields from the existing
|
||||
// config (only when the type is unchanged).
|
||||
const merged: Record<string, unknown> = { ...data.config };
|
||||
// config (only when the type is unchanged). Secrets are never sent back to the
|
||||
// client, so a blank incoming value means "keep the existing secret".
|
||||
const merged = { ...data.config };
|
||||
|
||||
if (existingConfig.type === data.config.type) {
|
||||
for (const key of EMAIL_TRANSPORT_SECRET_KEYS) {
|
||||
const incoming = (data.config as Record<string, unknown>)[key];
|
||||
if (incoming === undefined || incoming === '') {
|
||||
merged[key] = (existingConfig as Record<string, unknown>)[key];
|
||||
}
|
||||
}
|
||||
if (merged.type === 'SMTP_AUTH' && existingConfig.type === 'SMTP_AUTH' && !merged.password) {
|
||||
merged.password = existingConfig.password;
|
||||
}
|
||||
|
||||
if (merged.type !== 'SMTP_AUTH' && merged.type === existingConfig.type && !merged.apiKey) {
|
||||
merged.apiKey = existingConfig.apiKey;
|
||||
}
|
||||
|
||||
const config = ZEmailTransportConfigSchema.parse(merged);
|
||||
|
||||
@@ -148,7 +148,7 @@ export const updateOrganisationMemberRoleRoute = adminProcedure
|
||||
return;
|
||||
}
|
||||
|
||||
const targetRole = role as OrganisationMemberRole;
|
||||
const targetRole = role;
|
||||
|
||||
if (currentOrganisationRole === targetRole) {
|
||||
throw new AppError(AppErrorCode.INVALID_REQUEST, {
|
||||
|
||||
@@ -54,10 +54,11 @@ export const updateSubscriptionClaimRoute = adminProcedure
|
||||
}
|
||||
});
|
||||
|
||||
function getNewTruthyFlags(a: Partial<TClaimFlags>, b: Partial<TClaimFlags>): Record<keyof TClaimFlags, true> {
|
||||
function getNewTruthyFlags(a: Partial<TClaimFlags>, b: Partial<TClaimFlags>) {
|
||||
const flags: { [key in keyof TClaimFlags]?: true } = {};
|
||||
|
||||
for (const key in b) {
|
||||
// SAFETY: `b` is a Partial<TClaimFlags>, so its enumerable keys are TClaimFlags keys.
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
const typedKey = key as keyof TClaimFlags;
|
||||
|
||||
@@ -66,6 +67,5 @@ function getNewTruthyFlags(a: Partial<TClaimFlags>, b: Partial<TClaimFlags>): Re
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
return flags as Record<keyof TClaimFlags, true>;
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ export const createPasskeyRoute = authenticatedProcedure
|
||||
.input(ZCreatePasskeyRequestSchema)
|
||||
.output(ZCreatePasskeyResponseSchema)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
// SAFETY: ZRegistrationResponseJSONSchema validates the same fields RegistrationResponseJSON
|
||||
// declares; the assertion only restores the library type that zod inference loses.
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
const verificationResponse = input.verificationResponse as RegistrationResponseJSON;
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@ export const accessAuthRequest2FAEmailRoute = procedure
|
||||
|
||||
assertRateLimit(rateLimitResult);
|
||||
|
||||
const user = ctx.user;
|
||||
|
||||
// Get document and recipient by token
|
||||
const envelope = await prisma.envelope.findFirst({
|
||||
where: {
|
||||
|
||||
@@ -6,11 +6,11 @@ export const ZUpdateOrganisationEmailRequestSchema = z
|
||||
.object({
|
||||
emailId: z.string(),
|
||||
})
|
||||
.extend(
|
||||
.merge(
|
||||
ZCreateOrganisationEmailRequestSchema.pick({
|
||||
emailName: true,
|
||||
// replyTo: true
|
||||
}).shape,
|
||||
}),
|
||||
);
|
||||
|
||||
export const ZUpdateOrganisationEmailResponseSchema = z.void();
|
||||
|
||||
@@ -174,7 +174,7 @@ export const folderRouter = router({
|
||||
folderId: parentId,
|
||||
type,
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
throw new AppError(AppErrorCode.NOT_FOUND, {
|
||||
message: 'Parent folder not found',
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ export const profileRouter = router({
|
||||
|
||||
const parsedTeamId = teamId ? Number(teamId) : null;
|
||||
|
||||
if (typeof parsedTeamId === 'number') {
|
||||
if (parsedTeamId !== null) {
|
||||
if (Number.isNaN(parsedTeamId) || parsedTeamId <= 0) {
|
||||
throw new AppError(AppErrorCode.INVALID_BODY, {
|
||||
message: 'Invalid team ID provided',
|
||||
|
||||
@@ -138,7 +138,7 @@ export const updateTeamSettingsRoute = authenticatedProcedure
|
||||
|
||||
if (brandingCss === null) {
|
||||
sanitizedBrandingCss = null;
|
||||
} else if (typeof brandingCss === 'string') {
|
||||
} else if (brandingCss !== undefined) {
|
||||
const result = sanitizeBrandingCss(brandingCss);
|
||||
sanitizedBrandingCss = result.css.trim() === '' ? null : result.css;
|
||||
cssWarnings = result.warnings;
|
||||
|
||||
Reference in New Issue
Block a user