diff --git a/app/client/src/services/SettingsService.js b/app/client/src/services/SettingsService.js index f2789b3e1..96afe9eda 100644 --- a/app/client/src/services/SettingsService.js +++ b/app/client/src/services/SettingsService.js @@ -48,6 +48,11 @@ angular.module('reg') allowMinors: allowMinors }); }, + updateAllowAllEmails: function(allowAllEmails){ + return $http.put(base + 'allEmails', { + allowAllEmails: allowAllEmails + }); + }, }; } diff --git a/app/client/views/admin/settings/adminSettingsCtrl.js b/app/client/views/admin/settings/adminSettingsCtrl.js index c534ca89c..60be091d7 100644 --- a/app/client/views/admin/settings/adminSettingsCtrl.js +++ b/app/client/views/admin/settings/adminSettingsCtrl.js @@ -36,6 +36,18 @@ angular.module('reg') }); }; + $scope.updateAllowAllEmails = function () { + SettingsService + .updateAllowAllEmails($scope.settings.allowAllEmails) + .success(function (data) { + $scope.settings.allowAllEmails = data.allowAllEmails; + const successText = $scope.settings.allowAllEmails ? + "All emails are now allowed to register." : + "Only whitelisted emails are now allowed to register." + swal("Looks good!", successText, "success"); + }); + }; + // Whitelist -------------------------------------- SettingsService diff --git a/app/client/views/admin/settings/settings.html b/app/client/views/admin/settings/settings.html index ae67b32f0..9d711263b 100644 --- a/app/client/views/admin/settings/settings.html +++ b/app/client/views/admin/settings/settings.html @@ -99,6 +99,17 @@ +
+
+ + +
+
diff --git a/app/server/models/Settings.js b/app/server/models/Settings.js index 18eb3c1bb..2af2cccc1 100644 --- a/app/server/models/Settings.js +++ b/app/server/models/Settings.js @@ -39,6 +39,9 @@ var schema = new mongoose.Schema({ }, allowMinors: { type: Boolean + }, + allowAllEmails: { + type: Boolean } }); diff --git a/app/server/routes/api.js b/app/server/routes/api.js index 4be14e954..e597a381e 100644 --- a/app/server/routes/api.js +++ b/app/server/routes/api.js @@ -385,4 +385,17 @@ module.exports = function(router) { SettingsController.updateField('allowMinors', allowMinors, defaultResponse(req, res)); }); + /** + * [ADMIN ONLY] + * { + * allowAllEmails: Boolean + * } + * res: Settings + * + */ + router.put('/settings/allEmails', isAdmin, function(req, res){ + var allowAllEmails = req.body.allowAllEmails; + SettingsController.updateField('allowAllEmails', allowAllEmails, defaultResponse(req, res)); + }); + };