fix(striker-ui-api): move uuid assert for update mail server

main
Tsu-ba-me 11 months ago
parent 9f1c2dd2c3
commit 22fa465f1b
  1. 7
      striker-ui-api/src/lib/request_handlers/mail-server/getMailServerRequestBody.ts
  2. 7
      striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts

@ -1,9 +1,12 @@
import assert from 'assert';
import { REP_UUID } from '../../consts';
import { sanitize } from '../../sanitize';
export const getMailServerRequestBody = (
body: Partial<MailServerRequestBody>,
uuid?: string,
): MailServerRequestBody => {
const {
address: rAddress,
@ -25,6 +28,10 @@ export const getMailServerRequestBody = (
const security = sanitize(rSecurity, 'string', { fallback: 'none' });
const username = sanitize(rUsername, 'string');
if (uuid) {
assert(REP_UUID.test(uuid), `Expected valid UUIDv4; got [${uuid}]`);
}
assert.ok(address.length, `Expected address; got [${address}]`);
assert(

@ -1,8 +1,5 @@
import assert from 'assert';
import { RequestHandler } from 'express';
import { REP_UUID } from '../../consts';
import { execManageAlerts } from '../../execManageAlerts';
import { getMailServerRequestBody } from './getMailServerRequestBody';
import { stderr, stdout } from '../../shell';
@ -22,9 +19,7 @@ export const updateMailServer: RequestHandler<
let body: MailServerRequestBody;
try {
assert(REP_UUID.test(uuid), `Expected valid UUIDv4; got [${uuid}]`);
body = getMailServerRequestBody(rBody);
body = getMailServerRequestBody(rBody, uuid);
} catch (error) {
stderr(`Failed to process mail server input; CAUSE: ${error}`);

Loading…
Cancel
Save