mirror of
https://github.com/strapi/strapi.git
synced 2026-01-06 12:13:52 +00:00
PR feedback
This commit is contained in:
parent
e8b7bd478a
commit
7fdccc62ee
@ -43,4 +43,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -43,4 +43,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -43,4 +43,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -49,4 +49,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -44,4 +44,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -43,4 +43,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -43,4 +43,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -55,4 +55,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -43,4 +43,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -10,20 +10,20 @@ const _ = require('lodash');
|
||||
|
||||
const createDefaultEnvConfig = async (env) => {
|
||||
const pluginStore = strapi.store({
|
||||
environment: env,
|
||||
type: 'plugin',
|
||||
environment: env,
|
||||
type: 'plugin',
|
||||
name: 'email'
|
||||
});
|
||||
|
||||
const provider = _.find(strapi.plugins.email.config.providers, {provider: 'sendmail'});
|
||||
const value = _.assign({}, provider, {});
|
||||
|
||||
await pluginStore.set({key: 'provider', value});
|
||||
const provider = _.find(strapi.plugins.email.config.providers, {provider: 'sendmail'});
|
||||
const value = _.assign({}, provider, {});
|
||||
|
||||
await pluginStore.set({key: 'provider', value});
|
||||
return await strapi.store({
|
||||
environment: env,
|
||||
type: 'plugin',
|
||||
environment: env,
|
||||
type: 'plugin',
|
||||
name: 'email'
|
||||
}).get({key: 'provider'});
|
||||
}).get({key: 'provider'});
|
||||
};
|
||||
|
||||
const getProviderConfig = async (env) => {
|
||||
@ -34,18 +34,18 @@ const getProviderConfig = async (env) => {
|
||||
}).get({key: 'provider'});
|
||||
|
||||
if(!config) {
|
||||
config = await createDefaultEnvConfig(env);
|
||||
config = await createDefaultEnvConfig(env);
|
||||
}
|
||||
|
||||
return config;
|
||||
return config;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getProviderConfig,
|
||||
getProviderConfig,
|
||||
send: async (options, config, cb) => {
|
||||
// Get email provider settings to configure the provider to use.
|
||||
if(!config) {
|
||||
config = await getProviderConfig(strapi.config.environment);
|
||||
config = await getProviderConfig(strapi.config.environment);
|
||||
}
|
||||
|
||||
const provider = _.find(strapi.plugins.email.config.providers, { provider: config.provider });
|
||||
@ -57,6 +57,6 @@ module.exports = {
|
||||
const actions = provider.init(config);
|
||||
|
||||
// Execute email function of the provider for all files.
|
||||
return actions.send(options, cb);
|
||||
return actions.send(options, cb);
|
||||
}
|
||||
};
|
||||
|
||||
@ -49,4 +49,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ module.exports = async cb => {
|
||||
enabled: false,
|
||||
icon: 'twitter',
|
||||
key: '',
|
||||
secret: '',ad
|
||||
secret: '',
|
||||
callback: '/auth/twitter/callback'
|
||||
}
|
||||
};
|
||||
|
||||
@ -55,7 +55,7 @@ module.exports = {
|
||||
if (_.get(await store.get({key: 'advanced'}), 'email_confirmation') && user.confirmed !== true) {
|
||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.confirmed' }] }] : 'Your account email is not confirmed.');
|
||||
}
|
||||
|
||||
|
||||
if (user.blocked === true) {
|
||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.blocked' }] }] : 'Your account has been blocked by the administrator.');
|
||||
}
|
||||
@ -224,12 +224,15 @@ module.exports = {
|
||||
},
|
||||
|
||||
register: async (ctx) => {
|
||||
const settings = await strapi.store({
|
||||
const pluginStore = await strapi.store({
|
||||
environment: '',
|
||||
type: 'plugin',
|
||||
name: 'users-permissions',
|
||||
name: 'users-permissions'
|
||||
});
|
||||
|
||||
const settings = await pluginStore.get({
|
||||
key: 'advanced'
|
||||
}).get();
|
||||
});
|
||||
|
||||
if (!settings.allow_register) {
|
||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.advanced.allow_register' }] }] : 'Register action is currently disabled.');
|
||||
@ -287,16 +290,20 @@ module.exports = {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!settings.email_confirmation) {
|
||||
params.confirmed = true;
|
||||
}
|
||||
|
||||
const user = await strapi.query('user', 'users-permissions').create(params);
|
||||
|
||||
const jwt = strapi.plugins['users-permissions'].services.jwt.issue(_.pick(user.toJSON ? user.toJSON() : user, ['_id', 'id']));
|
||||
|
||||
if (settings.email_confirmation) {
|
||||
const settings = (await strapi.store({
|
||||
environment: '',
|
||||
type: 'plugin',
|
||||
name: 'users-permissions'
|
||||
}).get({ key: 'email' }))['email_confirmation'].options;
|
||||
const storeEmail = (await pluginStore.get({
|
||||
key: 'email'
|
||||
})) || {};
|
||||
|
||||
const settings = storeEmail['email_confirmation'] ? storeEmail['email_confirmation'].options : {};
|
||||
|
||||
settings.message = await strapi.plugins['users-permissions'].services.userspermissions.template(settings.message, {
|
||||
URL: `http://${strapi.config.currentEnvironment.server.host}:${strapi.config.currentEnvironment.server.port}/auth/email-confirmation`,
|
||||
@ -312,7 +319,7 @@ module.exports = {
|
||||
// Send an email to the user.
|
||||
await strapi.plugins['email'].services.email.send({
|
||||
to: user.email,
|
||||
from: (settings.from.email || settings.from.name) ? `"${settings.from.name}" <${settings.from.email}>` : undefined,
|
||||
from: (settings.from.email && settings.from.name) ? `"${settings.from.name}" <${settings.from.email}>` : undefined,
|
||||
replyTo: settings.response_email,
|
||||
subject: settings.object,
|
||||
text: settings.message,
|
||||
@ -348,6 +355,6 @@ module.exports = {
|
||||
key: 'advanced'
|
||||
}).get();
|
||||
|
||||
ctx.redirect(settings.email_confirmation_redirection);
|
||||
ctx.redirect(settings.email_confirmation_redirection || '/');
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user