mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
* API client to create and get an app license * Fixes unhandled promise rejection errors in redux config * License Page and Form * Adds getLicense action * Adds License key area to App Settings Form * Use license.token instead of license.license * Implement API client * Adds key icon to License Form * Adds License Success component * Render License Success on License Page when there is a license * Adds persistent flash actions and reducer to redux * Adds nag message middleware * Moves FlashMessage component to flash_message directory * Adds Persistent Flash component * Renders Persistent Flash component from Core Layout * Adds Kyle's styles * Change license validation message * Finishing touches for app config form license area * Handle revoked licenses * License Page hits setup endpoint * Display server errors on license form * Changes 0 allowed hosts to unlimited * Trims JWT token before sending to the server * GET setup page after submitting license
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
import { size, some, trim } from 'lodash';
|
|
|
|
import APP_CONSTANTS from 'app_constants';
|
|
import validJwtToken from 'components/forms/validators/valid_jwt_token';
|
|
|
|
const { APP_SETTINGS } = APP_CONSTANTS;
|
|
|
|
export default (formData) => {
|
|
const errors = {};
|
|
const {
|
|
authentication_type: authType,
|
|
kolide_server_url: kolideServerUrl,
|
|
license,
|
|
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 (!license) {
|
|
errors.license = 'License must be present';
|
|
}
|
|
|
|
if (license && !validJwtToken(trim(license))) {
|
|
errors.license = 'License is not a valid JWT token';
|
|
}
|
|
|
|
if (!orgName) {
|
|
errors.org_name = 'Organization Name must be present';
|
|
}
|
|
|
|
if (some([smtpSenderAddress, smtpServer, smtpUserName]) || (smtpPassword && smtpPassword !== APP_SETTINGS.FAKE_PASSWORD)) {
|
|
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 };
|
|
};
|