diff --git a/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js b/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js index 5e1e4c77c..04cdafebd 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js +++ b/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js @@ -6,8 +6,9 @@ const InitialStep = () => { return (

- Thanks for installing Talk! We sent an email to your team member. - While they finish setting up their account, start engaging with your readers now. + Thanks for installing Talk! We sent an email to verify your email + address. While you finish setting the account, you can start engaging + with your readers now.

diff --git a/client/coral-framework/helpers/validate.js b/client/coral-framework/helpers/validate.js index 639b513b4..69d81966f 100644 --- a/client/coral-framework/helpers/validate.js +++ b/client/coral-framework/helpers/validate.js @@ -3,5 +3,5 @@ export default { password: pass => (/^(?=.{8,}).*$/.test(pass)), confirmPassword: () => true, displayName: displayName => (/^[a-zA-Z0-9_]+$/.test(displayName)), - organizationName: org => (/^[a-zA-Z0-9_]+$/).test(org) + organizationName: org => (/^[a-zA-Z0-9_ ]+$/).test(org) }; diff --git a/routes/api/setup/index.js b/routes/api/setup/index.js index f8acd3d76..1391d20f2 100644 --- a/routes/api/setup/index.js +++ b/routes/api/setup/index.js @@ -1,39 +1,31 @@ const express = require('express'); -const errors = require('../../../errors'); - const SetupService = require('../../../services/setup'); -const SettingsService = require('../../../services/settings'); const router = express.Router(); +router.get('/available', (req, res, next) => { + SetupService + .isAvailable() + .then(() => { + res.json({available: true}); + }) + .catch(() => { + res.json({available: false}); + }); +}); + router.post('/', (req, res, next) => { - // Check if we have an install lock present. - if (process.env.TALK_INSTALL_LOCK === 'TRUE') { - return next(errors.ErrInstallLock); - } - - // Get the current settings, we are expecing an error here. - SettingsService - .retrieve() + SetupService + .isAvailable() .then(() => { - // We should NOT have gotten a settings object, this means that the - // application is already setup. Error out here. - return next(errors.ErrSettingsInit); - + // Allow the request to keep going here. + next(); }) .catch((err) => { - - // If the error is `not init`, then we're good, otherwise, it's something - // else. - if (err !== errors.ErrSettingsNotInit) { - return next(err); - } - - // Allow the request to keep going here. - return next(); + next(err); }); }, (req, res, next) => { diff --git a/services/setup.js b/services/setup.js index 449de1a0d..74ef1d431 100644 --- a/services/setup.js +++ b/services/setup.js @@ -9,6 +9,39 @@ const errors = require('../errors'); */ module.exports = class SetupService { + /** + * This returns a promise which resolves if the setup is available. + */ + static isAvailable() { + + // Check if we have an install lock present. + if (process.env.TALK_INSTALL_LOCK === 'TRUE') { + return Promise.reject(errors.ErrInstallLock); + } + + // Get the current settings, we are expecing an error here. + return SettingsService + .retrieve() + .then(() => { + + // We should NOT have gotten a settings object, this means that the + // application is already setup. Error out here. + return Promise.reject(errors.ErrSettingsInit); + + }) + .catch((err) => { + + // If the error is `not init`, then we're good, otherwise, it's something + // else. + if (err !== errors.ErrSettingsNotInit) { + return Promise.reject(err); + } + + // Allow the request to keep going here. + return; + }); + } + /** * This verifies that the current input for the setup is valid. */