mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Updated setup flow to rename default product
refs https://github.com/TryGhost/Team/issues/667 On clean and existing installs, the default product created should be named the same as the site title instead of the name in fixture. This change updates the default product's name to site title during the site setup. We use the Product name in Portal.
This commit is contained in:
parent
ec0a8c1d2f
commit
4d4286d255
2 changed files with 32 additions and 0 deletions
|
@ -32,6 +32,13 @@ module.exports = {
|
|||
|
||||
return auth.setup.setupUser(setupDetails);
|
||||
})
|
||||
.then((data) => {
|
||||
try {
|
||||
return auth.setup.doProduct(data, api.products);
|
||||
} catch (e) {
|
||||
return data;
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
return auth.setup.doSettings(data, api.settings);
|
||||
})
|
||||
|
|
|
@ -84,6 +84,30 @@ async function doSettings(data, settingsAPI) {
|
|||
return user;
|
||||
}
|
||||
|
||||
async function doProduct(data, productsAPI) {
|
||||
const context = {context: {user: data.user.id}};
|
||||
const user = data.user;
|
||||
const blogTitle = data.userData.blogTitle;
|
||||
|
||||
if (!blogTitle || typeof blogTitle !== 'string') {
|
||||
return user;
|
||||
}
|
||||
try {
|
||||
const page = await productsAPI.browse({limit: 1});
|
||||
|
||||
const [product] = page.products;
|
||||
if (!product) {
|
||||
return data;
|
||||
}
|
||||
|
||||
productsAPI.edit({products: [{name: blogTitle.trim()}]}, {context: context.context, id: product.id});
|
||||
} catch (e) {
|
||||
return data;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function sendWelcomeEmail(email, mailAPI) {
|
||||
if (config.get('sendWelcomeEmail')) {
|
||||
const data = {
|
||||
|
@ -121,5 +145,6 @@ module.exports = {
|
|||
assertSetupCompleted: assertSetupCompleted,
|
||||
setupUser: setupUser,
|
||||
doSettings: doSettings,
|
||||
doProduct: doProduct,
|
||||
sendWelcomeEmail: sendWelcomeEmail
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue