feat(core): server config online

This commit is contained in:
OldHawk
2018-01-27 01:55:58 +08:00
parent 086a922356
commit bb59fe26be
9 changed files with 129 additions and 19 deletions

View File

@@ -23,7 +23,35 @@ var serverNoticeConfig = config.meanTorrentConfig.serverNotice;
*/
exports.getSystemConfig = function (req, res) {
var config = shell.cat(path.resolve('./config/env/torrents.js'));
res.json({
configContent: config
});
if (req.user.isAdmin) {
res.json({
configContent: config
});
} else {
return res.status(403).json({
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
});
}
};
/**
* setSystemConfig
* @param req
* @param res
*/
exports.setSystemConfig = function (req, res) {
// eslint-disable-next-line new-cap
var cc = shell.ShellString(req.body.content);
if (req.user.isAdmin) {
cc.to('./config/env/torrents.js');
res.json({
message: 'SERVER.TORRENT_CONFIG_SAVE_SUCCESSFULLY'
});
} else {
return res.status(403).json({
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
});
}
};