mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 14:14:10 +00:00
change error messages
This commit is contained in:
parent
89221e8ee9
commit
54fda9c7c0
@ -83,10 +83,9 @@ For security reasons, keep storing the secret in an environment variable and use
|
||||
|
||||
strapi.config.set('admin.apiToken.salt', process.env.API_TOKEN_SALT);
|
||||
} else {
|
||||
const secretExample = crypto.randomBytes(16).toString('base64');
|
||||
throw new Error(
|
||||
`Missing apiToken.salt. Please set apiToken.salt in config/admin.js (ex: ${secretExample}).
|
||||
For security reasons, prefer storing the secret in an environment variable. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
||||
`Missing apiToken.salt. Please set apiToken.salt in config/admin.js (ex: you can generate one using Node with \`crypto.randomBytes(16).toString('base64')\`).
|
||||
For security reasons, prefer storing the secret in an environment variable and read it in config/admin.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,10 +54,9 @@ const decodeJwtToken = token => {
|
||||
*/
|
||||
const checkSecretIsDefined = () => {
|
||||
if (strapi.config.serveAdminPanel && !strapi.config.get('admin.auth.secret')) {
|
||||
const secretExample = crypto.randomBytes(16).toString('base64');
|
||||
throw new Error(
|
||||
`Missing auth.secret. Please set auth.secret in config/admin.js (ex: ${secretExample}).
|
||||
For security reasons, prefer storing the secret in an environment variable. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
||||
`Missing auth.secret. Please set auth.secret in config/admin.js (ex: you can generate one using Node with \`crypto.randomBytes(16).toString('base64')\`).
|
||||
For security reasons, prefer storing the secret in an environment variable and read it in config/admin.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -29,21 +29,22 @@ module.exports = async ({ strapi }) => {
|
||||
await getService('users-permissions').initialize();
|
||||
|
||||
if (!strapi.config.get('plugin.users-permissions.jwtSecret')) {
|
||||
const jwtSecret = crypto.randomBytes(16).toString('base64');
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
throw new Error(
|
||||
`Missing jwtSecret. Please, set jwtSecret for the users-permissions plugin in config/plugins.js or set environment variable JWT_SECRET (ex: ${jwtSecret}).
|
||||
For security reasons, prefer storing the secret in an environment variable. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
||||
`Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with \`crypto.randomBytes(16).toString('base64')\`).
|
||||
For security reasons, prefer storing the secret in an environment variable and read it in config/plugins.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
||||
);
|
||||
}
|
||||
|
||||
const jwtSecret = crypto.randomBytes(16).toString('base64');
|
||||
|
||||
strapi.config.set('plugin.users-permissions.jwtSecret', jwtSecret);
|
||||
|
||||
if (!process.env.JWT_SECRET) {
|
||||
strapi.fs.appendFile(process.env.ENV_PATH || '.env', `JWT_SECRET=${jwtSecret}\n`);
|
||||
const envPath = process.env.ENV_PATH || '.env';
|
||||
strapi.fs.appendFile(envPath, `JWT_SECRET=${jwtSecret}\n`);
|
||||
strapi.log.info(
|
||||
'The Users & Permissions plugin automatically generated a jwt secret and stored it in your .env file under the name JWT_SECRET.'
|
||||
`The Users & Permissions plugin automatically generated a jwt secret and stored it in ${envPath} under the name JWT_SECRET.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user