Added option to mark a list as not being allowed to be subscribed by public users using the form.

The settings is a checkbox in list create/edit.
This commit is contained in:
Tomas Bures 2017-04-14 08:48:49 -04:00
parent 80cf2c8888
commit c74232e9c5
7 changed files with 60 additions and 12 deletions

View file

@ -82,6 +82,10 @@ router.get('/create', passport.csrfProtection, (req, res) => {
data.csrfToken = req.csrfToken();
if (!('publicSubscribe' in data)) {
data.publicSubscribe = true;
}
res.render('lists/create', data);
});

View file

@ -176,9 +176,14 @@ router.get('/subscribe/:cid', (req, res, next) => {
router.get('/:cid', passport.csrfProtection, (req, res, next) => {
lists.getByCid(req.params.cid, (err, list) => {
if (!err && !list) {
err = new Error(_('Selected list not found'));
err.status = 404;
if (!err) {
if (!list) {
err = new Error(_('Selected list not found'));
err.status = 404;
} else if (!list.publicSubscribe) {
err = new Error(_('The list does not allow public subscriptions.'));
err.status = 403;
}
}
if (err) {
@ -501,9 +506,14 @@ router.post('/:cid/subscribe', passport.parseForm, corsOrCsrfProtection, (req, r
let testsPass = subTimeTest && addressTest;
lists.getByCid(req.params.cid, (err, list) => {
if (!err && !list) {
err = new Error(_('Selected list not found'));
err.status = 404;
if (!err) {
if (!list) {
err = new Error(_('Selected list not found'));
err.status = 404;
} else if (!list.publicSubscribe) {
err = new Error(_('The list does not allow public subscriptions.'));
err.status = 403;
}
}
if (err) {