diff --git a/striker-ui-api/src/lib/request_handlers/mail-server/getMailServerRequestBody.ts b/striker-ui-api/src/lib/request_handlers/mail-server/getMailServerRequestBody.ts index f618d179..1fbff0f6 100644 --- a/striker-ui-api/src/lib/request_handlers/mail-server/getMailServerRequestBody.ts +++ b/striker-ui-api/src/lib/request_handlers/mail-server/getMailServerRequestBody.ts @@ -1,9 +1,12 @@ import assert from 'assert'; +import { REP_UUID } from '../../consts'; + import { sanitize } from '../../sanitize'; export const getMailServerRequestBody = ( body: Partial, + 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( diff --git a/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts b/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts index 0c8cf858..a665f4b1 100644 --- a/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts +++ b/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts @@ -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}`);