Added new setup endpoint

This commit is contained in:
Wyatt Johnson
2017-02-07 10:02:23 -07:00
parent f47638ae07
commit cdc81c4fc5
4 changed files with 53 additions and 27 deletions
@@ -6,8 +6,9 @@ const InitialStep = () => {
return (
<div className={styles.step}>
<p>
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.
</p>
<Button>Launch Talk</Button>
<Button cStyle='black'>Close this Installer</Button>
+1 -1
View File
@@ -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)
};
+16 -24
View File
@@ -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) => {
+33
View File
@@ -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.
*/