mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
* add a js validator that makes smtp server port required * specifying that the InputField should be a number. this doesn't work, but i think that it should. * casting the port as an int as a stop-gap fix * email doesn't already have to be enabled to be enabled * don't return the smtp password from the API * show a fake placeholder password if the username is also set * error type for @groob
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
import { size, some } from 'lodash';
|
|
|
|
export default (formData) => {
|
|
const errors = {};
|
|
const {
|
|
authentication_type: authType,
|
|
kolide_server_url: kolideServerUrl,
|
|
org_name: orgName,
|
|
password: smtpPassword,
|
|
sender_address: smtpSenderAddress,
|
|
server: smtpServer,
|
|
port: smtpServerPort,
|
|
user_name: smtpUserName,
|
|
} = formData;
|
|
|
|
if (!kolideServerUrl) {
|
|
errors.kolide_server_url = 'Kolide Server URL must be present';
|
|
}
|
|
|
|
if (!orgName) {
|
|
errors.org_name = 'Organization Name must be present';
|
|
}
|
|
|
|
if (some([smtpSenderAddress, smtpPassword, smtpServer, smtpUserName])) {
|
|
if (!smtpSenderAddress) {
|
|
errors.sender_address = 'SMTP Sender Address must be present';
|
|
}
|
|
|
|
if (!smtpServer) {
|
|
errors.server = 'SMTP Server must be present';
|
|
}
|
|
|
|
if (!smtpServerPort) {
|
|
errors.server = 'SMTP Server Port must be present';
|
|
}
|
|
|
|
if (authType !== 'authtype_none') {
|
|
if (!smtpUserName) {
|
|
errors.user_name = 'SMTP Username must be present';
|
|
}
|
|
|
|
if (!smtpPassword) {
|
|
errors.password = 'SMTP Password must be present';
|
|
}
|
|
}
|
|
}
|
|
|
|
const valid = !size(errors);
|
|
|
|
return { valid, errors };
|
|
};
|