From ab3d7ac2bba3365aea58abe218ce1ea7259c8f48 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Tue, 24 Apr 2018 12:01:53 +0800 Subject: [PATCH] feat(torrents): add access limit to maker group settings of torrent uploader --- config/env/torrents.js | 27 ++++++++++++------- .../controllers/about.client.controller.js | 2 ++ .../client/config/core.client.route-filter.js | 6 ++--- .../controllers/core.server.controller.js | 2 +- .../controllers/uploads.client.controller.js | 2 ++ .../authentication.client.controller.js | 2 ++ .../score/score.client.controller.js | 2 ++ .../status/warning.client.controller.js | 2 ++ .../controllers/vip.client.controller.js | 2 ++ 9 files changed, 34 insertions(+), 13 deletions(-) diff --git a/config/env/torrents.js b/config/env/torrents.js index ecad1ddf..94b9cab6 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -211,18 +211,27 @@ module.exports = { }, /** - * @adminAccess + * @access * - * setting ip access for menu of admin center + * setting ip access for site menu * - * @limit: set whether to limit ip to access admin center - * @limitedIp: list all allow ip to access admin center, otherwise can not to access - * If you limited some vpn ip to access it, please add the vpn ip into the @limitedIp array - * If no limited ip, set the @limit to false + * @admin: setting of access for admin center + * @limit: set whether to limit ip to access admin center + * @limitedIp: list all allow ip to access admin center, otherwise can not to access + * If you limited some vpn ip to access it, please add the vpn ip into the @limitedIp array + * If no limited ip, set the @limit to false + * @upload: setting of access for torrents uploader + * @limitToMakerGroup: setting whether limit the access to maker group for torrents uploader + * if false, everyone can upload torrent */ - adminAccess: { - limit: false, - limitedIp: ['127.0.0.1'] + access: { + admin: { + limit: false, + limitedIp: ['127.0.0.1'] + }, + upload: { + limitToMakerGroup: false + } }, /** diff --git a/modules/about/client/controllers/about.client.controller.js b/modules/about/client/controllers/about.client.controller.js index c5f9e06f..ba035bef 100644 --- a/modules/about/client/controllers/about.client.controller.js +++ b/modules/about/client/controllers/about.client.controller.js @@ -39,6 +39,7 @@ vm.passwordConfig = MeanTorrentConfig.meanTorrentConfig.password; vm.examinationConfig = MeanTorrentConfig.meanTorrentConfig.examination; vm.chatConfig = MeanTorrentConfig.meanTorrentConfig.chat; + vm.accessConfig = MeanTorrentConfig.meanTorrentConfig.access; vm.groupTorrentType = localStorageService.get('maker_last_selected_type') || 'movie'; vm.searchTags = []; @@ -84,6 +85,7 @@ passwordConfig: vm.passwordConfig, examinationConfig: vm.examinationConfig, chatConfig: vm.chatConfig, + accessConfig: vm.accessConfig, user: vm.user }); diff --git a/modules/core/client/config/core.client.route-filter.js b/modules/core/client/config/core.client.route-filter.js index 3d978a14..a979c5ee 100644 --- a/modules/core/client/config/core.client.route-filter.js +++ b/modules/core/client/config/core.client.route-filter.js @@ -40,9 +40,9 @@ } } else { if (toState.name.startsWith('admin.')) { - var adminAccessConfig = MeanTorrentConfig.meanTorrentConfig.adminAccess; + var accessConfig = MeanTorrentConfig.meanTorrentConfig.access; - if (adminAccessConfig.limit) { + if (accessConfig.admin.limit) { if ($rootScope.ipIdentify) { $rootScope.ipIdentify = false; return; @@ -50,7 +50,7 @@ event.preventDefault(); UsersService.getMyIp(function (res) { - if (Authentication.user && !adminAccessConfig.limitedIp.includes(res.ip)) { + if (Authentication.user && !accessConfig.admin.limitedIp.includes(res.ip)) { $state.transitionTo('access-deny'); } else { $rootScope.ipIdentify = true; diff --git a/modules/core/server/controllers/core.server.controller.js b/modules/core/server/controllers/core.server.controller.js index 942df698..79a89d6a 100644 --- a/modules/core/server/controllers/core.server.controller.js +++ b/modules/core/server/controllers/core.server.controller.js @@ -91,7 +91,7 @@ function getSafeMeanTorrentConfig(req, cfg) { //ignore adminAccess config items for normal users if (req.user && !req.user.isOper) { - newCfg.adminAccess = undefined; + newCfg.access.admin = undefined; } return newCfg; diff --git a/modules/torrents/client/controllers/uploads.client.controller.js b/modules/torrents/client/controllers/uploads.client.controller.js index eee06e83..543b09ac 100644 --- a/modules/torrents/client/controllers/uploads.client.controller.js +++ b/modules/torrents/client/controllers/uploads.client.controller.js @@ -34,6 +34,7 @@ vm.passwordConfig = MeanTorrentConfig.meanTorrentConfig.password; vm.examinationConfig = MeanTorrentConfig.meanTorrentConfig.examination; vm.chatConfig = MeanTorrentConfig.meanTorrentConfig.chat; + vm.accessConfig = MeanTorrentConfig.meanTorrentConfig.access; vm.resourcesTags = MeanTorrentConfig.meanTorrentConfig.resourcesTags; vm.torrentType = MeanTorrentConfig.meanTorrentConfig.torrentType; @@ -114,6 +115,7 @@ passwordConfig: vm.passwordConfig, examinationConfig: vm.examinationConfig, chatConfig: vm.chatConfig, + accessConfig: vm.accessConfig, user: vm.user }); diff --git a/modules/users/client/controllers/authentication.client.controller.js b/modules/users/client/controllers/authentication.client.controller.js index f19f790f..095bbc9c 100644 --- a/modules/users/client/controllers/authentication.client.controller.js +++ b/modules/users/client/controllers/authentication.client.controller.js @@ -30,6 +30,7 @@ vm.passwordConfig = MeanTorrentConfig.meanTorrentConfig.password; vm.examinationConfig = MeanTorrentConfig.meanTorrentConfig.examination; vm.chatConfig = MeanTorrentConfig.meanTorrentConfig.chat; + vm.accessConfig = MeanTorrentConfig.meanTorrentConfig.access; vm.authentication = Authentication; vm.getPopoverMsg = PasswordValidator.getPopoverMsg; @@ -92,6 +93,7 @@ passwordConfig: vm.passwordConfig, examinationConfig: vm.examinationConfig, chatConfig: vm.chatConfig, + accessConfig: vm.accessConfig, user: vm.authentication.user }); diff --git a/modules/users/client/controllers/score/score.client.controller.js b/modules/users/client/controllers/score/score.client.controller.js index 9f3c5fa5..b844bd8e 100644 --- a/modules/users/client/controllers/score/score.client.controller.js +++ b/modules/users/client/controllers/score/score.client.controller.js @@ -30,6 +30,7 @@ vm.passwordConfig = MeanTorrentConfig.meanTorrentConfig.password; vm.examinationConfig = MeanTorrentConfig.meanTorrentConfig.examination; vm.chatConfig = MeanTorrentConfig.meanTorrentConfig.chat; + vm.accessConfig = MeanTorrentConfig.meanTorrentConfig.access; vm.lang = getStorageLangService.getLang(); vm.user = Authentication.user; @@ -85,6 +86,7 @@ passwordConfig: vm.passwordConfig, examinationConfig: vm.examinationConfig, chatConfig: vm.chatConfig, + accessConfig: vm.accessConfig, user: vm.user }); diff --git a/modules/users/client/controllers/status/warning.client.controller.js b/modules/users/client/controllers/status/warning.client.controller.js index d367eaa5..1c89f61c 100644 --- a/modules/users/client/controllers/status/warning.client.controller.js +++ b/modules/users/client/controllers/status/warning.client.controller.js @@ -34,6 +34,7 @@ vm.passwordConfig = MeanTorrentConfig.meanTorrentConfig.password; vm.examinationConfig = MeanTorrentConfig.meanTorrentConfig.examination; vm.chatConfig = MeanTorrentConfig.meanTorrentConfig.chat; + vm.accessConfig = MeanTorrentConfig.meanTorrentConfig.access; vm.lang = getStorageLangService.getLang(); @@ -72,6 +73,7 @@ passwordConfig: vm.passwordConfig, examinationConfig: vm.examinationConfig, chatConfig: vm.chatConfig, + accessConfig: vm.accessConfig, user: vm.user }); diff --git a/modules/vip/client/controllers/vip.client.controller.js b/modules/vip/client/controllers/vip.client.controller.js index ba3271c5..3b1e2868 100644 --- a/modules/vip/client/controllers/vip.client.controller.js +++ b/modules/vip/client/controllers/vip.client.controller.js @@ -36,6 +36,7 @@ vm.passwordConfig = MeanTorrentConfig.meanTorrentConfig.password; vm.examinationConfig = MeanTorrentConfig.meanTorrentConfig.examination; vm.chatConfig = MeanTorrentConfig.meanTorrentConfig.chat; + vm.accessConfig = MeanTorrentConfig.meanTorrentConfig.access; vm.torrentType = MeanTorrentConfig.meanTorrentConfig.torrentType; vm.resourcesTags = MeanTorrentConfig.meanTorrentConfig.resourcesTags; @@ -82,6 +83,7 @@ passwordConfig: vm.passwordConfig, examinationConfig: vm.examinationConfig, chatConfig: vm.chatConfig, + accessConfig: vm.accessConfig, user: vm.user });