Added email unfreeze for verified email config

refs https://github.com/TryGhost/Team/issues/912

- When instance has "verified" email configuration it should remove email freeze and disallow future feezes
This commit is contained in:
Naz 2021-07-27 14:07:11 +04:00 committed by naz
parent 06788f0b6a
commit 8bc4d00fe6
2 changed files with 20 additions and 2 deletions

View File

@ -62,8 +62,9 @@ async function initDatabase({config, logging}) {
* (There's more to do to make this true)
* @param {object} options
* @param {object} options.ghostServer
* @param {object} options.config
*/
async function initCore({ghostServer}) {
async function initCore({ghostServer, config}) {
debug('Begin: initCore');
// URL Utils is a bit slow, put it here so the timing is visible separate from models
@ -81,6 +82,7 @@ async function initCore({ghostServer}) {
debug('Begin: settings');
const settings = require('./server/services/settings');
await settings.init();
await settings.syncEmailSettings(config.get('hostSettings:emailVerification:verified'));
debug('End: settings');
// The URLService is a core part of Ghost, which depends on models. It needs moving from the frontend to make this clear.
@ -323,7 +325,7 @@ async function bootGhost() {
// Step 4 - Load Ghost with all its services
debug('Begin: Load Ghost Services & Apps');
await initCore({ghostServer});
await initCore({ghostServer, config});
await initFrontend();
const ghostApp = await initExpressApps();
await initDynamicRouting();

View File

@ -56,6 +56,22 @@ module.exports = {
}
},
/**
* Handles email setting synchronization when email has been verified per instance
*
* @param {boolean} configValue current email verification value from local config
*/
async syncEmailSettings(configValue) {
const isEmailDisabled = SettingsCache.get('email_verification_required');
if (configValue === true && isEmailDisabled) {
return await models.Settings.edit([{
key: 'email_verification_required',
value: false
}], {context: {internal: true}});
}
},
obfuscatedSetting,
isSecretSetting,
hideValueIfSecret