32 lines
885 B
JavaScript
Raw Normal View History

2017-11-17 11:17:20 +01:00
'use strict';
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
2017-12-04 16:43:24 +01:00
const path = require('path');
const _ = require('lodash');
const fs = require('fs');
const uuid = require('uuid/v4');
2017-11-17 11:17:20 +01:00
module.exports = cb => {
2017-12-04 16:43:24 +01:00
if (!_.get(strapi.plugins['users-permissions'], 'config.jwtSecret')) {
try {
2017-12-12 15:13:27 +01:00
const jwtSecret = uuid();
2017-12-04 16:43:24 +01:00
fs.writeFileSync(path.join(strapi.config.appPath, 'plugins', 'users-permissions', 'config', 'jwt.json'), JSON.stringify({
2017-12-12 15:13:27 +01:00
jwtSecret
2017-12-04 16:43:24 +01:00
}, null, 2), 'utf8');
2017-12-12 15:13:27 +01:00
_.set(strapi.plugins['users-permissions'], 'config.jwtSecret', jwtSecret);
2017-12-04 16:43:24 +01:00
} catch(err) {
strapi.log.error(err);
}
}
2017-11-20 14:35:24 +01:00
strapi.plugins['users-permissions'].services.userspermissions.updatePermissions(cb);
2017-11-17 11:17:20 +01:00
};